Jump to content

return SPECIFIC sql results


avenged

Recommended Posts

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?
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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?
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.