Im trying to count() the number of values in a multidimensional array using COUNT_RECURSIVE but im struggling with where i should place the count.
heres a snippet of my code, hope that someone can make some sence of what im trying to do. Here is a working example of my page: http://www.mortalis.com/?mainDiv=/forums/testrc.php
// 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, COUNT_RECURSIVE); // want to count number of members in each class
$adminbits = $val;
eval("\$groupbits .= \"".fetch_template("rollcall_group2")."\";");
}
}
// build forum jump
construct_forum_jump();
eval('print_output("' . fetch_template('rollcall2') . '");');
As you can see on the right of each rollcall_group there are Total $classname vars where i would like to display the total number of members per class... even break it into avctive & inactive... but one step at a time hu 😉
Hope someone can help 😃 thx