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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.