TeddyKiller Posted April 3, 2010 Share Posted April 3, 2010 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.. Quote Link to comment Share on other sites More sharing options...
ialsoagree Posted April 3, 2010 Share Posted April 3, 2010 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.