Jump to content

How do I do this - Adding up all unread's and echo it out in a number


TeddyKiller

Recommended Posts

Simple PHP Query to get what is needed.

$query = mysql_query("select * from `sent_messages` where `status`='unread' and `to_id`='$user->id'");

This is the query to get the data. I'm just needing to bring out all the rows into a number.

If there are 5 rows, so 5 mails unread. It'll echo out.. 5.

 

This is probably using a foreach, but I'm not sure?

 

Hope you can help!

P.S Sorry I'm posting alot recently. I'm working more than usual and running into the basics all over again..

Link to comment
Share on other sites

If you *just* need the number or rows (but not the actual info in the rows themselves) you should use:

 

SELECT COUNT(*) FROM sent_messages WHERE status = 'unread' AND to_id = '$user->id'

 

If you need the info in the rows too, your current query will work, you just need to use mysql_num_rows($query) to get the number of results.

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.