I would just wanted to ask for a better idea for this. the scenario is this:
1. Display messages on a clickable table row. if the message is already read the row can’t be clicked
2. Onced clicked it will open a popup window used for replying to the message. when the window is closed the page should refresh.
The problem is I can only get the last row data. it seems session variables are overwritten.
<?php
//Display Messages Starts Here
$msg = "SELECT * FROM messages WHERE sid=". $_SESSION['SESS_SERVICE_ID'] ."";
$resulta = mysql_query($msg)or die(mysql_error());
while($row = mysql_fetch_array($resulta))
{
if($row['status']=='deleted'){
echo "<tr bgcolor=#AAAAAA>";
echo "<td>" . date("Y-m-d",strtotime($row['stamp'])) . "</td>";
echo "<td>" . $row['msisdn'] . "</td>";
echo "<td width=100%>" . $row['data'] . "</td>";
echo "</tr>";
}
else{
// id like to use this to a popup form for reply
echo "<tr onmouseover='ChangeColor(this, true);'
onmouseout='ChangeColor(this, false);'
onclick=\"DoNav();\">";
echo "<td>" . date("Y-m-d",strtotime($row['stamp'])) . "</td>";
echo "<td>" . $row['msisdn'] . "</td>";
$_SESSION['SESS_MSG_ID'] = $row['id'];
$_SESSION['SESS_MSG_DATA'] = $row['data'];
echo "<td width=100%>" . $row['data'] . "</td>";
$_SESSION['SESS_MSG_NUM'] = $row['msisdn'];
echo "</tr>";
}
}
?>
You are setting a
$_SESSIONvariable, and this one is overwritten every time.You better store it in an array, like:
And then change the onClick to:
And of course in DoNav function:
And then in reply.php, get the ID with
$_GET['id'];and get the data from the session like this:Besides the SESS_MSG_DATA you can store them all in this array: