...

View Full Version : update not working



harkly
12-01-2010, 07:59 PM
I am setting up a message board and right now I am trying to set up a 'Mark as Unread" button.

It is working to some extent, everything will change but not all at once. This is what is happening

user1 is logged into the message board.
They select "All" and click the "Mark as Unread" button.
All messages that are sent by another user are changed to reflect the new status. However any message created by
user1 is not. But if you select only the ones created by user1 and "update" they will do so.

I have a good idea of the issue but not sure how to resolve it.

I have 2 scenarios running at the same time

sender vs receiver
user2 vs user1

sender vs receiver
user1 vs user2



$clientID = user1


if($sender == $clientID) {
if($_GET['unread_x']){
$totalIDs = count($my_array);
for ( $i=0; $i < $totalIDs; $i++ ) {
$query2 = ("UPDATE threads SET s_status=0 WHERE id='$my_array[$i]'");
$result2 = mysql_query($query2) or die(mysql_error());
} // END for
}
}
else {
if($_GET['unread_x']){
$totalIDs = count($my_array);

for ( $i=0; $i < $totalIDs; $i++ ) {
$query2 = ("UPDATE threads SET r_status=0 WHERE id='$my_array[$i]'");
$result2 = mysql_query($query2) or die(mysql_error());
} // END for
}
}


When messages that have diffrent "senders" are selected it will only do 1, how do I get it to do all?

Rowsdower!
12-01-2010, 08:17 PM
What's the difference between your uses of r_status and s_status? It seems to me that this might be the problem, but without seeing more code I can only guess...

harkly
12-01-2010, 08:43 PM
I'm using the r_status & s_status to document the status of the message based on what the receiver(r) or sender(s) does.
such as if
r_status = 0 then either it is new or a new reply has been posted
r_status = 1 all replies have been read
r_status = 2 recevier has deleted the message

I think I have my issue figured out.

I'm send the data in an array but was not carrying that thru the whole process but doing it in the individual sections of the code

changed my code to seems to be working :o


$totalIDs = count($my_array);
for ( $i=0; $i < $totalIDs; $i++ ) {
$sql2 = mysql_query("SELECT sender FROM threads WHERE id='$my_array[$i]'");
while($r = mysql_fetch_array($sql2)) {
$sender=$r['sender'];

if($clientID==$sender) {
if($_GET['unread_x']){
$query12 = ("UPDATE threads SET s_status=0 WHERE id='$my_array[$i]'");
$result12 = mysql_query($query12) or die(mysql_error());
} // END ($_GET['unread_x'])
} // END if($clientID==$sender)
else {
if($_GET['unread_x']){
$query12 = ("UPDATE threads SET r_status=0 WHERE id='$my_array[$i]'");
$result12 = mysql_query($query12) or die(mysql_error());
} // END if($_GET['unread_x'])
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum