check if mysql query returns empty set

wjh2303

New Member
Messages
139
Reaction score
0
Points
0
how can i check if a mysql query in php has returned an empty set.
I have a page that requires two queries, but want to format it slightly differently if the first query returns the empty set, i.e:

if(1stquery=emptyset){
format this way
}
else{
format that way
}

hope thats clear enough

TIA
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
Code:
$result = mysql_query('blah blah blah this is your query');
if ($result) {
     if (mysql_num_rows($result) == 0) {
        // do one thing
     }
     else {
        // do another thing
     }
}
 
Top