Cronje Posted June 1, 2006 Share Posted June 1, 2006 I'm trying to determine the number of results from a SELECT, but am having trouble. My code:$query = mysql_query("SELECT * FROM tablename WHERE name='xxx'");$num = mysql_num_rows($query);It works fine when 'xxx' is in the table, but when it finds none, 'echo $num;' doesn't display anything.Help please!-Cronje Quote Link to comment https://forums.phpfreaks.com/topic/10936-number-of-results-problem/ Share on other sites More sharing options...
samshel Posted June 1, 2006 Share Posted June 1, 2006 How about this ?$query = mysql_query("SELECT * FROM tablename WHERE name='xxx'");$num = (int)mysql_num_rows($query); Quote Link to comment https://forums.phpfreaks.com/topic/10936-number-of-results-problem/#findComment-40833 Share on other sites More sharing options...
Cronje Posted June 1, 2006 Author Share Posted June 1, 2006 That worked perfectly. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/10936-number-of-results-problem/#findComment-40839 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.