Hi, I have a simple sql statement and I would like to perform a different action depending on the number of rows returned.
$result_lists = mysql_num_rows(mysql_query("SELECT * FROM db_table"));
//To see the number returned
print_r($result_lists);
switch($result_lists) {
case($result_lists == 0):
//To prove which option is actually happening
print_r('lists==0: '.$result_lists);
break;
case($result_lists > 1):
//To prove which option is actually happening
print_r('lists>1: '.$result_lists);
break;
case($result_lists == 1):
//To prove which option is actually happening
print_r('lists==1: '.$result_lists);
break;
}
If 1 or more row is found, then the correct case is used, however, if zero rows are returned, for some reason the (> 1) case is carried out.
Can anyone see what might be going wrong?
Any advice appreciated.
Thanks.