duancaishi1897 2014-09-09 11:22
浏览 74

如何在on语句中添加多个mysql语句

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>";
  • 写回答

2条回答 默认 最新

  • douzhenao6515 2014-09-09 13:08
    关注

    You can create a stored procedure and call it from your script

    评论

报告相同问题?