matvespa Posted August 29, 2011 Share Posted August 29, 2011 Hi. I having trouble with counting rows in phpmyadmin. It works fine this way: $result_rows = mysql_query("SELECT * FROM events"); But when i modify the code to this it doesnt work at all. $result_rows = mysql_query("SELECT * FROM events WHERE category = 'adults' ORDER BY 'date'"); Any idea what is wrong? Link to comment https://forums.phpfreaks.com/topic/245932-count-rows-in-phpmyadmin/ Share on other sites More sharing options...
cunoodle2 Posted August 29, 2011 Share Posted August 29, 2011 if you want to know the number of results you have to use "count" like this.. $result_rows = mysql_query("SELECT count(*) FROM events WHERE category = 'adults' ORDER BY 'date'"); If that is not what you are looking for then you will have to give me more info. Your post is vague as you don't tell us if there are any error messages or exactly what the issue is. Link to comment https://forums.phpfreaks.com/topic/245932-count-rows-in-phpmyadmin/#findComment-1263055 Share on other sites More sharing options...
matvespa Posted August 29, 2011 Author Share Posted August 29, 2011 $result_rows = mysql_query("SELECT count(*) FROM events WHERE category = 'adults' ORDER BY 'date'"); while($row = mysql_fetch_array($result_rows)){ $id = $row["id"]; echo $result_rows; I got a Resource id #5 error. Link to comment https://forums.phpfreaks.com/topic/245932-count-rows-in-phpmyadmin/#findComment-1263062 Share on other sites More sharing options...
voip03 Posted August 29, 2011 Share Posted August 29, 2011 $result_rows = mysql_query("SELECT * FROM events WHERE category = 'adults' ORDER BY 'date'"); Remove single quotation mark $result_rows = mysql_query("SELECT * FROM events WHERE category = adults ORDER BY date"); You can use mysql_num_rows() to count number of rows. Link to comment https://forums.phpfreaks.com/topic/245932-count-rows-in-phpmyadmin/#findComment-1263066 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.