I am trying to write a script for a messaging system and want to know if I can use the SELECT and UPDATE one right the other statement
so it would go like this:
1) user clicks on unread message
2) while the page is get the selected info from SELECT statement it updating the message_status from unread to read
I got the unread counter working but for it to go down I need to go to my db and change it to read for it to go down.
code i working with
<?php
$get_con = mysql_query("SELECT hash, user_one, user_two FROM message_group WHERE user_one='$my_id' OR user_two='$my_id'");
while($run_con = mysql_fetch_array($get_con)){
$hash = $run_con['hash'];
$user_one = $run_con['user_one'];
$user_two = $run_con['user_two'];
if($user_one == $my_id){
$select_id = $user_two;
}else{
$select_id = $user_one;
}
$user_get = mysql_query("SELECT username FROM users WHERE id='$select_id'");
$run_user = mysql_fetch_array($user_get);
$select_username = $run_user['username'];
echo "<p><a href='conversation.php?hash=$hash'>$select_username</a></p>";