avenged Posted March 12, 2006 Share Posted March 12, 2006 k, I would like to know how exactly I would go about selecting certain rows out of a mysql query. Example:the query:"SELECT * FROM pm WHERE reciever='$user_id'";How would I sort through the results it returns to get only ones that contain the value of 1, and nothing else? Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 12, 2006 Share Posted March 12, 2006 I don't understand your question. You have a query that will return ONLY rows where the field named reciever contains the value of $userid. So what would you like to see that's only equal to 1?[code]"SELECT * FROM pm WHERE reciever='$user_id' AND somethingelse = '1'";[/code] Quote Link to comment Share on other sites More sharing options...
avenged Posted March 12, 2006 Author Share Posted March 12, 2006 ok. I have written a function for my private messaging system that I have written. It's supposed to return the total number of PM's a user has in his inbox.[code]function getTotalPM($id){ $pm_query = "SELECT * FROM pm WHERE reciever='$id'"; echo mysql_num_rows(mysql_query($pm_query));}[/code]What I want to know is if I can limit the results that this function returns to ones that only have the value of 1(in this case, PM's that have not been read) so I can then make a new function(getNewPM()) to return the number of unread PM's the user has. How would I modify this function to return the intended results? Quote Link to comment Share on other sites More sharing options...
avenged Posted March 12, 2006 Author Share Posted March 12, 2006 anyone?? Quote Link to comment Share on other sites More sharing options...
keeB Posted March 12, 2006 Share Posted March 12, 2006 [code]function getTotalPM($id){ $pm_query = "SELECT * FROM pm WHERE reciever='$id' and read = 1"; echo mysql_num_rows(mysql_query($pm_query));}[/code] 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.