query_first will only give you the first result row.
If this is what you want you could use
[sql]
select count(*) from user where userclassid=$groupinfo[userclassid]
[/sql]
But I wouldn't do this, as it would cause one additional query for each class.
With the query I posted before you can retrieve the information you want (how many users are in each class) with one query.
Therefore you should use smth. like this:
PHP Code:
$classes = $DB_Site->query("SELECT userclassid, COUNT(userclassid) AS total FROM " . TABLE_PREFIX . "user BROUP BY userclassid");
while ($class = $DB_Site->fetch_array($classes))
echo "There are $class[total] members in class id $class[userclassid]";
Btw: I think your whole code needs some major rework as it seems like you are executing 5 additional queries per user (!).
PHP Code:
$getuserstatus=$DB_site->query_first("SELECT title FROM useractive WHERE useractiveid=$user[activestatus]");
$getuserrace=$DB_site->query_first("SELECT title FROM userrace WHERE userraceid=$user[userraceid]");
$getusergroup=$DB_site->query_first("SELECT title FROM usergroup WHERE usergroupid=$user[usergroupid]");
$getuserrank=$DB_site->query_first("SELECT title FROM userrank WHERE userrankid=$user[userrankid]");
$getusergender=$DB_site->query_first("SELECT title FROM usergender WHERE usergenderid=$user[usergenderid]");
I think this is not necessary. You can have all those fields in the first query and thus being returned in array $user:
PHP Code:
$users = $DB_site->query("SELECT $magelofieldselect $surnamefieldselect user.username, user.userrankid, user.activestatus, userclass.title, user.userraceid, user.userid, user.usergenderid, user.userclassid, user.usergroupid,
useractive.title AS userstatus, userrace.title AS userrace, userrank.title AS userrank, usergender.title AS usergender, usergroup.title AS usergroup
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "useractive AS useractive ON (useractive.ueractiveid = user.activestatus)
LEFT JOIN " . TABLE_PREFIX . "userrace AS userrace ON (userrace.userraceid = user.userraceid)
LEFT JOIN " . TABLE_PREFIX . "userrank AS userrake ON (userrank.userrankid = user.userrankid)
LEFT JOIN " . TABLE_PREFIX . "usergender AS usergender ON (usergender.usergenderid = user.usergenderid)
LEFT JOIN " . TABLE_PREFIX . "userclass AS userclass ON (userclass.userclassid = user.userclassid)
LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON (userfield.userid = user.userid)
LEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup ON (usergroup.usergroupid = user.usergroupid)
WHERE usergroup.rollcall = 1 AND user.userclassid != 0 ORDER BY user.userclassid, user.username ASC
");