harkly
11-22-2010, 04:20 PM
Not sure how to explain this, so please bear with me.
I am trying to verify if a userName is in a query but not sure how to check for it. There can be one 2 names in the query and I need to check to see if one ($clientID) is in it.
user has to be logged in so $clientID is set
My code:
$sql = mysql_query("SELECT author FROM replies WHERE thread=$id");
while($r = mysql_fetch_array($sql)) {
$author=$r['author'];
}
if($author==$clientID){
echo "True";
}
else {
echo "False";
}
So $author is either one of 2 names, $clientID or whatever
so for example - the author table
$author
Jack
Jill
Jill
Jack
Jill
With Jack = $clientId
when I run the query it will be false because Jill comes up last, but I need it to be true because Jack was in it as well.
I am trying to verify if a userName is in a query but not sure how to check for it. There can be one 2 names in the query and I need to check to see if one ($clientID) is in it.
user has to be logged in so $clientID is set
My code:
$sql = mysql_query("SELECT author FROM replies WHERE thread=$id");
while($r = mysql_fetch_array($sql)) {
$author=$r['author'];
}
if($author==$clientID){
echo "True";
}
else {
echo "False";
}
So $author is either one of 2 names, $clientID or whatever
so for example - the author table
$author
Jack
Jill
Jill
Jack
Jill
With Jack = $clientId
when I run the query it will be false because Jill comes up last, but I need it to be true because Jack was in it as well.