Read messages

1912Dummy's Avatar, Join Date: Mar 2013
Light Poster
been a while but we are back

i was wondering if someone can help me fix this problem

let me explain first:
if you send a user a message and the other user reads it it has to changed to 1
but if you read the message again to look at it it may not change it to 1
but thats the problem if i read the message again before the other user reads it it also change it to 1

no idea what i do wrong but he is the code:
$req2 = $db->Select("select, pm.stmp, pm.msg, as userid, users.username, users.avatar, pm.del, pm.tstmp, pm.deliver, users.avatarcol from pm, users where and order by pm.id2 DESC LIMIT 5",$id);


					if(count($req2) >= 1) {//if message exist 

						for($i=0;$i<count($req2);$i++){ echo $req2[$i]['id'].chr(5).$req2[$i]['userid'].chr(5).$req2[$i]['username'].chr(5).$req2[$i]['msg'].chr(5).$req2[$i]['stmp'].chr(5).$req2[$i]['del'].chr(5).$req2[$i]['tstmp'].chr(5).$req2[$i]['deliver'].chr(5).$req2[$i]['avatar']."\r\n".chr(3); }        
$req10 = $db->Select('select u1 from pm where id=? and id2="1"',$id);
					    $db->Alter("update pm set u2r='1' where id=? and id2='1'",$id);
					    $db->Alter("update pm set u1r='1' where id=? and id2='1'",$id);					   

					} else {

						echo 'Message not exist.';

						for ($i = 0; $i < 8; $i++) echo ''.chr(5);

we have in the table
id u1r u2r

this gonna be tricky but hope you get it
if ME u1r send a message to u2r it will be 1 0
but seems when i wanna read my message again it do 1 1
can't be it must stay 1 0

even when the other user send me a message then it will be 0 1

hope you get my hard words

shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Your Table is being altered either way and it should be updating both the fields.

update pm set u1r='1', u2r = '0'
1912Dummy's Avatar, Join Date: Mar 2013
Light Poster
hello sir,

if i use this what you showed me
then it will be the same result as before
it was ment to be that the current user must have 1 if he / she read it
in either way if i open it again it must do nothing

i know i was never been good to explain things haha ask my teachers

so any other ideas please.