How do I count rows with MySQL?
Moderator: General Moderators
How do I count rows with MySQL?
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
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: How do I count rows with MySQL?
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);