Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 25 Feb 2004, 17:49
NickPR NickPR is offline
 
Join Date: Feb 2004
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:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #2  
Old 25 Feb 2004, 18:17
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Real name: Andreas
Seems like I don't understand anything ^.^
What do you want to count?
Reply With Quote
  #3  
Old 25 Feb 2004, 18:28
NickPR NickPR is offline
 
Join Date: Feb 2004
want to count the sub totals of each class:

heres a working example of my page : http://www.mortalis.com/?mainDiv=/forums/testrc.php

Thanks

Last edited by NickPR : 25 Feb 2004 at 18:34.
Reply With Quote
  #4  
Old 25 Feb 2004, 18:39
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Real name: Andreas
OK ... these things like Bards, Beastlords, etc come from table userclass which is linked to table user by userclassid.

And you want to know how many members are in each class, right?

Then use this query


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #5  
Old 25 Feb 2004, 19:22
NickPR NickPR is offline
 
Join Date: Feb 2004
thx KirbyDE. I think this will work if i could only use it properly :P

I first assigned it to a var: $result = $DB_site->query_first("select userclassid, count(userclassid) as total from user group by userclassid");

and then it just showed as 'Array' in each case of $result in the output. So i modified the string in the html template to call $result[total] but now it outputs what appears to be the total of all users (506).

Where am i going wrong ?

heres the modified code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #6  
Old 25 Feb 2004, 20:23
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Real name: Andreas
query_first will only give you the first result row.

If this is what you want you could use

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Btw: I think your whole code needs some major rework as it seems like you are executing 5 additional queries per user (!).


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I think this is not necessary. You can have all those fields in the first query and thus being returned in array $user:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do not count invisible admin in online count totals calorie vBulletin 3.0 Full Releases 12 29 Feb 2008 18:39

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 08:55.

Layout Options | Width: Wide Color: