Page 1 of 1

how to display a table rows amount total SQL

Posted: Fri Jul 09, 2004 7:57 pm
by fresh
hi,

was wondering how to go about echoing to a htm doc, the total amount of entries in an SQL table.... Im looking to display the total amount of members the site has, something like:

Blah.com's Registered Members (100) <-- echoed 'id' row in members table

help is appreciated, thanks

Posted: Fri Jul 09, 2004 8:06 pm
by tim

Code: Select all

<?php
$sql = mysql_query("SELECT * FROM table_name");
$membercount = mysql_num_rows($sql);

echo "There are $membercount users";

// All you need to modify is table_name with the actual name of the table 

?>

hey

Posted: Fri Jul 09, 2004 8:20 pm
by fresh
thanks alot, I am so slow to learn sql, I appreciate the help... thanks again ;)

Posted: Fri Jul 09, 2004 8:21 pm
by tim
welcome

:wink: