MyBB Community Forums

Full Version: Total Members of a group.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
So I've been working on this but it doesn't come out correctly so I'll see if someone can help.
In a forums statistics you can view the total amount of members like such.

[Image: 7debf218fda645b778d9218e582d71ac.png]

I want to display the total members of a specific group on the forums.
i.e I want to display the total number of members in the Admin group on the public forums.

I want it to automatically increase obviously.
Just run a query that counts the users in the group.
I know it shows up in the cap I can probably make a quick script for you to use. Feel free to add me on Skype (same as forum name).
$count = $db->fetch_field( $db->query( "SELECT COUNT(*) as numberofmembers FROM ".TABLE_PREFIX."users WHERE `usergroup` = {Usergroup} ), 'numberofmembers' );

Not my query, credits to Cedric
(2015-06-21, 08:53 AM)Akay Wrote: [ -> ]
$count = $db->fetch_field( $db->query( "SELECT COUNT(*) as numberofmembers FROM ".TABLE_PREFIX."users WHERE `usergroup` = {$usergroup} ), 'numberofmembers' );

Not my query, credits to Cedric

Small error, {Usergroup} must be {$usergroup}, where:

$usergroup = 4;

for admins.
I've been awake almost 2 days now and can hardly funcation. 

1. It's for clients
2. Group ID is 8

Anyways if anyone has an idea to the query can you post it here and I'll make some changes. My heads fried and I'm gonna bed.
(2015-06-21, 05:02 PM)Nasyr Wrote: [ -> ]I've been awake almost 2 days now and can hardly funcation. 

1. It's for clients
2. Group ID is 8

Anyways if anyone has an idea to the query can you post it here and I'll make some changes. My heads fried and I'm gonna bed.

Post your current code you have in the PHP file.
I think that Akay's statement is correct, for usergroup 8 it is then:


$count = $db->fetch_field( $db->query( "SELECT COUNT(*) as numberofmembers FROM ".TABLE_PREFIX."users WHERE `usergroup` = 8 "), 'numberofmembers' ); 

Where I had to correct another small typing error by adding a double quote just after the 8 of the usergroup.
(2015-06-22, 12:03 PM)Ad Bakker Wrote: [ -> ]I think that Akay's statement is correct, for usergroup 8 it is then:


$count = $db->fetch_field( $db->query( "SELECT COUNT(*) as numberofmembers FROM ".TABLE_PREFIX."users WHERE `usergroup` = 8 "), 'numberofmembers' ); 

Where I had to correct another small typing error by adding a double quote just after the 8 of the usergroup.

Does anyone know how to do this with additional usergroups as well?
(2015-06-22, 12:03 PM)Ad Bakker Wrote: [ -> ]I think that Akay's statement is correct, for usergroup 8 it is then:


$count = $db->fetch_field( $db->query( "SELECT COUNT(*) as numberofmembers FROM ".TABLE_PREFIX."users WHERE `usergroup` = 8 "), 'numberofmembers' ); 

Where I had to correct another small typing error by adding a double quote just after the 8 of the usergroup.

usergroup = 8 count Number of user in gid 8 only. can I count all of gid ?
Pages: 1 2