I know that the "while" loop will not execute if $result is empty, but that is not enough for me. I would like to test the difference between an invalid query and a successful query with zero rows returned
Expand|Select|Wrap|Line Numbers
- if ($result = $db->query($sql)){
- $recFound = false;
- while ($c = $result->fetch_assoc()) {
- ..... some processing steps here.....
- $recFound = true;
- }
- if ($recFound){
- $cResponse = subStr( $cResponse, 0, strlen($cResponse)-3) )
- }else{
- $cResponse = "none";
- }
- }
Expand|Select|Wrap|Line Numbers
- if (mysql_num_rows($result) == 0) {
- echo "No rows found, nothing to print so am exiting";
- exit;
- }