...

View Full Version : display total records onto page



wayne3503
08-01-2007, 04:39 PM
Ok on the admin side of the content management system im building, I have a fille called "view_users.php", which will diplay a list of all the users who are registered in the db. What I am wondering is how I would go about setting up a query or whatever to look at the total number of records and return it to the page so that I could have something on my page say "645,527 members and counting"

thanks for the help

BWiz
08-01-2007, 04:54 PM
$link = @mysql_connect ( "localhost", "user", "pass" )
or die ( mysql_error() );
$db = @mysql_select_db ( "databaseName", $link )
or die ( mysql_error() );
$query = mysql_query ( "SELECT * FROM tableName WHERE 1" );
$count = mysql_fetch_rows ( $query );

print $count;
I think this works, I'm not sure, haven't tested.

wayne3503
08-01-2007, 05:09 PM
After making the needed changes this is the error I get...


Fatal error: Call to undefined function mysql_fetch_rows() in C:\xampp\htdocs\viewable\hsrevised\cms\admin\view_users.php on line 7
Here is my code as of now

$link = @mysql_connect ( "localhost", "root", "" )
or die ( mysql_error() );
$db = @mysql_select_db ( "reg", $link )
or die ( mysql_error() );
$query = mysql_query ( "SELECT * FROM users WHERE 1" );
$count = mysql_fetch_rows ( $query );

print $count;

Figured one thing out. I replaced mysql_fetch_rows with "mysql_num_rows" and that brought back a number. Now how would I put the message after it to finish it off?

Thanks for your help

BWiz
08-01-2007, 05:12 PM
Sorry, I think I had a mind block! Its actually: mysql_num_rows.

wayne3503
08-01-2007, 05:23 PM
I figured out the message part now to...Thanks for the start :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum