I have currently built myself a message script which allows users in my game to send messages to other players and recieve them etc. I have also built some script which lets users know if they have new mail, but the only problem is, if they then look in their mail inbox, then click on another page, it will still say they have new mail, as the script just searchs the message table in a database for records which the equal the players user id, and also is not saved.
So basically, if the totalrows > 1, it will show the mail notification, but this is not helping!
I want a script that would continue to search the database for new messages. Which comes to the next problem, the msgs are displayed using the code below (sorry its a bit messy at the mo as its going through testing!)
<?
$colname_Recordset1 = "1";
if (isset($_SESSION['MM_Username'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_london, $london);
$query_Recordset1 = sprintf("SELECT * FROM msg WHERE spid = '%s' AND saved = 0 ORDER BY sent DESC", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $london) or die(mysql_error());
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$cur = 1;
echo "<ol>";
while ($totalRows_Recordset1 >= $cur) {
$row = mysql_fetch_array($Recordset1);
$pid = $row["pid"];
$msg = $row["msg"];
$mid = $row['mid'];
$date = $row['sent'];
$date = date('d-m-y G:i a',$date);
?>
<tr>
<td height="21">Message from <? echo "<a href='player_info.php?pid=$pid'>$pid</a>" ?> </td>
</tr>
<tr>
<td height="21">Recieved: <? echo $date ?></td>
</tr>
<tr>
<td height="21"><? echo $msg ?> </td>
</tr>
<tr>
<td height="21"><? echo "<a href='email_delete.php?mid=$mid'>delete msg </a>" ?> | <? echo "<a href='email_save.php?mid=$mid'>save msg</a>" ?> | <? echo "<a href='email_reply.php?pid=$pid'>reply</a>" ?></td>
</tr><?php
$cur++;
}
echo "</ol>";
?>
How could i make it so that the code will automatically set a column named 'READ' to 1 for all messages currently in the inbox? This would help me also create the code to check for new mail as i could then search for posts where 'READ' = 0.
Thanks for any help