Page 1 of 1
How do I count rows with MySQL?
Posted: Fri Apr 11, 2008 4:54 pm
by xenoalien
How do I count rows with MySQL? I am making a wallpaper website for fun and kicks located at
http://www.wallpapersearch.net and would like to know how I could count all the results of a database table? Basically this is so that I can show visitors how much wallpaper there is within my database. Thanks
Re: How do I count rows with MySQL?
Posted: Fri Apr 11, 2008 4:56 pm
by Christopher
SELECT COUNT(*) AS total FROM wallpapers
Re: How do I count rows with MySQL?
Posted: Fri Apr 11, 2008 7:25 pm
by robseek
If you want to find out how many rows have been returned from a particular sql query then you would do this:
Code: Select all
$sql = "SELECT color FROM wallpaper WHERE id = $input_id;";
$result = mysql_query($sql);
$num_of_rows = mysql_num_rows($result);