[SOLVED] how to display a table rows amount total SQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

how to display a table rows amount total SQL

Post 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
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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 

?>
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

hey

Post by fresh »

thanks alot, I am so slow to learn sql, I appreciate the help... thanks again ;)
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

welcome

:wink:
Post Reply