Mr Chris Posted September 7, 2007 Share Posted September 7, 2007 Hi, In the below query: <? $SQL = "SELECT * from xxxx"; $result = mysql_query($SQL) OR die(mysql_error()); while ($row = mysql_fetch_assoc($result)){ echo 'Blah, Blah Blah'; } if (!$result){ echo 'No results'; } ?> If I find no results I want the no results message outputted. But It does not work. Can anyone explain why? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/68405-no-results-found-simple-help/ Share on other sites More sharing options...
graham23s Posted September 7, 2007 Share Posted September 7, 2007 have you tried: if (($result) == 0) { echo 'No results'; } Graham Quote Link to comment https://forums.phpfreaks.com/topic/68405-no-results-found-simple-help/#findComment-343898 Share on other sites More sharing options...
Mr Chris Posted September 7, 2007 Author Share Posted September 7, 2007 Yep, Still the same thing though, just absolutely nothing outputted? Just blank space... Any other suggestions Quote Link to comment https://forums.phpfreaks.com/topic/68405-no-results-found-simple-help/#findComment-343903 Share on other sites More sharing options...
noidtluom Posted September 8, 2007 Share Posted September 8, 2007 Use mysql_num_rows to check how many rows you get. Then if (mysql_num_rows($SQL) == 0) { echo 'No results'; } Quote Link to comment https://forums.phpfreaks.com/topic/68405-no-results-found-simple-help/#findComment-344207 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.