Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:12 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05557 seconds
  • Memory Usage 2,527KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadedmode.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete