![]() |
|
|
Thread Tools |
|
#1
|
||||
|
||||
|
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:
No members have liked this post.
|
||||
|
#2
|
||||
|
||||
|
Seems like I don't understand anything ^.^
What do you want to count? No members have liked this post.
|
|
#3
|
|||
|
|||
|
want to count the sub totals of each class:
heres a working example of my page : http://www.mortalis.com/?mainDiv=/forums/testrc.phpThanks ![]() No members have liked this post.
Last edited by NickPR : 25 Feb 2004 at 18:34. |
|
#4
|
||||
|
||||
|
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
No members have liked this post.
|
||||
|
#5
|
||||
|
||||
|
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:
No members have liked this post.
|
||||
|
#6
|
||||||||||||||||
|
||||||||||||||||
|
query_first will only give you the first result row.
If this is what you want you could use
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:
Btw: I think your whole code needs some major rework as it seems like you are executing 5 additional queries per user (!).
I think this is not necessary. You can have all those fields in the first query and thus being returned in array $user:
No members have liked this post.
|
||||||||||||||||
![]() |
«
Previous Thread
|
Next Thread
»
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 | |
|
|
| New To Site? | Need Help? |
All times are GMT. The time now is 21:11.

i keep getting a figure for the total number in the array at told level (i.e. the number of usergroups).
: 

