How Can I Show That Total Membership ?

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
saqib389
Forum Commoner
Posts: 44
Joined: Wed Nov 30, 2005 2:13 am

How Can I Show That Total Membership ?

Post by saqib389 »

how can i show that total membership in my site...

means how many ppl have been registered.. and the number of registered users i want to display

for example

total memberships : 102

please can any one tell me the code how can i add this feature...
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Code: Select all

SELECT COUNT(*) AS `count` FROM `users`
:?
saqib389
Forum Commoner
Posts: 44
Joined: Wed Nov 30, 2005 2:13 am

Post by saqib389 »

i did this thing.. but its not showing the TOTAL MEMBERSHIP
:cry:

any tutorial ?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

What does your db table storing the users look like?
saqib389
Forum Commoner
Posts: 44
Joined: Wed Nov 30, 2005 2:13 am

Post by saqib389 »

yes i m using mysql

here is the infoo

users table i creat in mysql

Code: Select all

CREATE TABLE users ( 
  userid int(25) NOT NULL auto_increment, 
  first_name varchar(25) NOT NULL default '', 
  last_name varchar(25) NOT NULL default '', 
  email_address varchar(255) NOT NULL default '', 
  username varchar(25) NOT NULL default '', 
  password varchar(255) NOT NULL default '', 
  info text NOT NULL, 
  signup_date datetime NOT NULL default '0000-00-00 00:00:00', 
  activated enum('0','1') default NULL, 
  decrypted_password varchar(255) NOT NULL default '', 
  PRIMARY KEY  (userid), 
  UNIQUE KEY username (username) 
) TYPE=MyISAM COMMENT='Mysiteinfo';
then i want to get the total membership then i write this code

Code: Select all

$results = mysql_query("select count(*) as userid from users");

$get_row = mysql_fetch_array($results); // get 1 row

$totalmembers = $get_row['userid'];

echo $totalmembers;

still its not showing the total memberships
please tell me what shuld i do
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

That query should do it. What happens when you run the query right in the database (either command line or PHPMyAdmin?)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

may want to check what $get_row has in it

var_export()
Post Reply