Web Hosting Talk







View Full Version : How do I output a count of my "approved" accounts?


Chris`
07-05-2008, 06:38 PM
Hey WHT,

So, I'm messing with a php script of mine, and I want to add a total count of my "approved" accounts. So we have a database "members" and a table "approved". In the approved table, 1 stands for approved, and 0 stands for.. well, not approved. So, how can I just count the approved accounts?



$query = "SELECT approved, COUNT(approved) FROM members GROUP BY approved";
$result = mysql_query($query) or die(mysql_error());

// Print out result
while($row = mysql_fetch_array($result)){
echo "There are ". $row['COUNT(approved)'] ." Approved Accounts";
echo "<br />";
}


As now, this outputs the following:
There are 3 Approved Accounts
There are 1 Approved Accounts

The problem is that there are 4 demo accounts in there, 3 are unapproved, and 1 is approved. So how do I fix this?

Thanks,
~ Chris`

Chris`
07-05-2008, 07:16 PM
Neverind, we figured it out..