how do i count the records in a database? i am new to php, and cant find an answer anywhere on the web.
thanks for the help.
add up the rows in each table.
$query_results = mysql_db_query("database_name","SELECT COUNT(*) as total FROM table");
$results = mysql_fetch_object($query_results);
echo "Total rows in table: ",$results->total;
Just for clarity, counting records is not actually a PHP task, but a database management task (ie SQL). Be careful about using count() if your database contains nulls in the counted fields (for example: SELECT Count(*) as total FROM table WHERE age < 10). Different databases handle the counting of rows with null fields differently.
A piece of advice <ol> <li>You need to learn SQL <li>I suggest buying "SQL in ten minutes" by Ben Forta (www.forta.com) - this is a short and straight to the point book, that a newbie like you should find useful. <li> www.arsdigita.com/books/ has a good book on SQL and it is free. <li>Read php manual on using mysql functions. </ol> Di