MyBB Community Forums

Full Version: Pull counts from SPECIFIC usergroup.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to pull counts from a specific usergroup that counts the sex of the users in that group.

As of right now it's pulling counts from the entire forum instead of just that usergroup.


    $num_male = $db->fetch_field($db->simple_select("userfields", "COUNT(ufid) as count", "fid3='Male'"), "count");
    $num_female = $db->fetch_field($db->simple_select("userfields", "COUNT(ufid) as count", "fid3='Female'"), "count");
    $num_unspecified = $stats_cache['numusers'] - $num_male - $num_female; 

I tried adding in a where clause as suggested by someone else to pull from a usergroup but now I just keep running into SQL errors and the page won't even load.

$num_male = $db->fetch_field($db->simple_select("userfields", "COUNT(ufid) as count", "WHERE usergroup IN ('4')", "fid3='Male'"), "count");
$num_female = $db->fetch_field($db->simple_select("userfields", "COUNT(ufid) as count", "WHERE usergroup IN ('4')", "fid3='Female'"), "count");
$num_other = $db->fetch_field($db->simple_select("userfields", "COUNT(ufid) as count", "WHERE usergroup IN ('4')", "fid3='Other'"), "count");

I'm lost, and if someone could point me in the right direction on how to count these variables just for usergroup 4 that would be lovely.

Thanks Smile
Why didnt creat in admincp?
I'm not sure what you mean?

I'm pulling this script to show on the statistics page. Can't do that from the adminCP.