Jump to content

MySQL PHP issue


unkn0wndj

Recommended Posts

Alright I was wanting to pull information from a MySQL database. Heres the code im using

[code]$mnum = mysql_query("select * from messages where msg_recieverid='$_SESSION[usrid]'");

$mnumber = mysql_num_rows($mnum);[/code]

Alright so I was wondering.. I need to have the msg_recieverid still included because that's what tells it to pull only from their ID, but what I really need to know is msg_read='U' because that says that the message is unread and thats the whole purpose of it. So how can I make a command that lets me pull the number of msg_read='U' that someone has for their msg_recieverid..

Please help
Link to comment
https://forums.phpfreaks.com/topic/5830-mysql-php-issue/
Share on other sites

Assuming you just need the count, and not the actual messages, then the following should suffice:

[code]SELECT COUNT(*) AS cnt FROM messages WHERE msg_recieverid='$_SESSION[usrid]' AND msg_read ='U'[/code]

Then pull back the single row containing the count with mysql_fetch_array().
Link to comment
https://forums.phpfreaks.com/topic/5830-mysql-php-issue/#findComment-20783
Share on other sites

[!--quoteo(post=358465:date=Mar 25 2006, 11:51 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Mar 25 2006, 11:51 PM) [snapback]358465[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Assuming you just need the count, and not the actual messages, then the following should suffice:

[code]SELECT COUNT(*) AS cnt FROM messages WHERE msg_recieverid='$_SESSION[usrid]' AND msg_read ='U'[/code]

Then pull back the single row containing the count with mysql_fetch_array().
[/quote]

Sorry i dont understand what you mean by

" Then pull back the single row containing the count with mysql_fetch_array()."

Could you please copy what the code needs to contain for that to work :)

oh btw the recieverid is a number
Link to comment
https://forums.phpfreaks.com/topic/5830-mysql-php-issue/#findComment-20788
Share on other sites

[!--quoteo(post=358605:date=Mar 26 2006, 02:06 PM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Mar 26 2006, 02:06 PM) [snapback]358605[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Try

$count = mysql_result($mnum, 0, 0);
[/quote]


Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/vhosts/www.nowiby.com/templates/topnav.php on line 20
Link to comment
https://forums.phpfreaks.com/topic/5830-mysql-php-issue/#findComment-20972
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.