Jump to content

extract the total number of members?


satan

Recommended Posts

I'm having a hard time extracting the total number of members for this site: http://community.vitacost.com

 

I want the number to show up next to "Active VitaSpace profiles". Can someone help me out? I'm a total beginner so if you could explain in layman's terms I'd appreciate it very much.

 

Thanks...

Link to comment
https://forums.phpfreaks.com/topic/133876-extract-the-total-number-of-members/
Share on other sites

Or you could do it the long way. (For variety's sake.

 

<?php

include 'php/config.php' //singular mysql DB connection file

$q = "SELECT * FROM `members`"; //the query string

$res = mysql_query($q,$conn); //store the result of the query on the DB

$rows = mysql_num_rows($res); //count the number of rows in the result string

?>

 

That would give you the total number of entries in the table `members`. If you wanted active members you would have to perform further operations.

 

If you are storing validating member data in the `members` table you might want to exclude it by adding a WHERE conditional:

 

$q = "SELECT * FROM `members` WHERE `validating` = false";

 

Or something similar. I would just use the above though, much quicker. mysql_num_rows() has it's uses, many of them, but this is best handled within the query it self.

 

-David

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.