How would one go about counting the sub parts of the array? i've tried various count() variations but can't seem to crack it

i keep getting a figure for the total number in the array at told level (i.e. the number of usergroups).
the reason i ask is because i have a modified version of showgroups which acts as a rollcall and want to show the total number of members belonging to each class (not forum group).
heres the snippit *cough* of code which refers to the building of my array:
PHP Code:
// Start fetch members
$users = $DB_site->query("
SELECT DISTINCT
$magelofieldselect $surnamefieldselect user.username, user.userrankid, user.activestatus, userclass.title, user.userraceid, user.userid, user.usergenderid, user.userclassid,
user.usergroupid
FROM user
LEFT JOIN usergender ON (usergender.usergenderid = user.usergenderid)
LEFT JOIN userclass ON (userclass.userclassid = user.userclassid)
LEFT JOIN userfield ON (userfield.userid = user.userid)
LEFT JOIN usergroup ON (usergroup.usergroupid = user.usergroupid)
WHERE usergroup.rollcall = 1 AND user.userclassid != 0 ORDER BY userclassid, username ASC
");
// Count totals
$totalactive = $DB_site->query_first("
SELECT COUNT(*) AS users
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "usergroup ON (usergroup.usergroupid = user.usergroupid)
WHERE usergroup.rollcall=1 AND user.userclassid != 0 AND user.activestatus !=0
");
$totalinactive = $DB_site->query_first("
SELECT COUNT(*) AS users
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "usergroup ON (usergroup.usergroupid = user.usergroupid)
WHERE usergroup.rollcall=1 AND user.userclassid != 0 AND user.activestatus =0
");
$totalall = $DB_site->query_first("
SELECT COUNT(*) AS users
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "usergroup ON (usergroup.usergroupid = user.usergroupid)
WHERE usergroup.rollcall=1 AND user.userclassid != 0
");
while ($user = $DB_site->fetch_array($users)) {
if (($smodcount++ % 2) == 0) {
$backcolor = "#94CDF8";
} else {
$backcolor = "#6699CC";
}
process_userinfo();
$userclassid = $user['userclassid'];
$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]");
if (!$grouptitle[$usergroupid]) {
$grouptitle[$userclassid] = $user['title'];
}
eval("\$groupinfo[$userclassid] .= \"".fetch_template("rollcall_bit2")."\";");
}
if (is_array($groupinfo)) {
while(list($key, $val) = each($groupinfo)) {
$classname = $grouptitle["$key"];
if (substr($classname,-1)!="s") {
$classname.="s";
}
$result = count($classname);
$adminbits = $val;
eval("\$groupbits .= \"".fetch_template("rollcall_group2")."\";");
}
}
// build forum jump
construct_forum_jump();
eval('print_output("' . fetch_template('rollcall2') . '");');