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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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.