View Single Post
  #1  
Old 02-25-2004, 04:49 PM
NickPR NickPR is offline
 
Join Date: Feb 2004
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default count() in showgroups.php

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') . '");'); 
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01233 seconds
  • Memory Usage 1,820KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete