MyBB Community Forums
Total Members of a group. - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: 1.8 Support (https://community.mybb.com/forum-175.html)
+--- Forum: General Support (https://community.mybb.com/forum-176.html)
+--- Thread: Total Members of a group. (/thread-172165.html)

Pages: 1 2


Total Members of a group. - Nasyr - 2015-06-20

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.


RE: Total Members of a group. - Lektz - 2015-06-21

Just run a query that counts the users in the group.


RE: Total Members of a group. - mikeorman - 2015-06-21

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).


RE: Total Members of a group. - Sazze - 2015-06-21

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

Not my query, credits to Cedric


RE: Total Members of a group. - Ad Bakker - 2015-06-21

(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.


RE: Total Members of a group. - Nasyr - 2015-06-21

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.


RE: Total Members of a group. - Sazze - 2015-06-22

(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.


RE: Total Members of a group. - Ad Bakker - 2015-06-22

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.


RE: Total Members of a group. - isoldehn - 2017-11-06

(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?


RE: Total Members of a group. - Kiddo Monster - 2018-04-26

(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 ?