SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: get just one result
-
Aug 4, 2003, 11:36 #1
- Join Date
- Aug 2003
- Location
- USA
- Posts
- 33
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
get just one result
is there any way to get one specific name from a database
...for example, I have a table named user_message
and a row called the_user which keeps track of which user posted the message,
but what I want to do is compare the username of the CURRENT_userto the user that posted the message
(ie. a user already in the row the_user )
so that another user cant change the same message.
PHP Code:$check_user_query = "select * from user_message where
the_user = \"CURRENT_user\"";
$check_user = mysql_query($check_user_query) or
die(mysql_error());
if(mysql_num_rows($check_user) != 0){
return "TRUE";
} else {
return "FALSE";
}
Thanks
-
Aug 4, 2003, 13:57 #2
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
it will return FALSE if you put in a value for a user that has not posted a message
in effect, you are saying "get all the messages for user X, and if there are any, return TRUE"
-
Aug 4, 2003, 14:58 #3
- Join Date
- Aug 2003
- Location
- USA
- Posts
- 33
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
so what query should i use to check if the current user is the same as the one specific user that posted the message?
-
Aug 4, 2003, 15:16 #4
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
select the_user
from user_messages
where message_id = N
you need to specify which message you're talking about
the query will return exactly one result
then compare this in your code to the current user
Bookmarks