MyBB Community Forums

Full Version: How to show total admin number
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to show total admin,mod number in index_stats . how can I do?
ex. Total authorized: 11
$countadmins = $db->write_query( "SELECT COUNT(*) AS totaladmins FROM ".TABLE_PREFIX."users WHERE `usergroup` = 4 " );
$totaladmins = my_number_format($db->fetch_field($countadmins, "totaladmins"));

If you add this somewhere in your index.php file, you can then echo the variable {$totaladmins} in one of the index templates, for example index_stats

it will show how many users there are in the group 4 (admin).
(2015-09-05, 08:37 PM)Sazze Wrote: [ -> ]
$countadmins = $db->write_query( "SELECT COUNT(*) AS totaladmins FROM ".TABLE_PREFIX."users WHERE `usergroup` = 4 " );
$totaladmins = my_number_format($db->fetch_field($countadmins, "totaladmins"));

If you add this somewhere in your index.php file, you can then echo the variable {$totaladmins} in one of the index templates, for example index_stats

it will show how many users there are in the group 4 (admin).

thank you its work but I want to show total admin and moderator not only one group
how about

	$query = $db->query('
			SELECT COUNT(uid) AS team_count FROM '.TABLE_PREFIX.'users WHERE usergroup IN
			(SELECT gid FROM '.TABLE_PREFIX.'usergroups WHERE cancp=1 OR issupermod=1 OR canmodcp=1)
			');
	$team_count = $db->fetch_field($query, 'team_count', 1);
thank you!

		<?php
		$countadmins = $db->write_query( "SELECT COUNT(*) AS totaladmins FROM ".TABLE_PREFIX."users WHERE `usergroup` = 4 " );
		$totaladmins = my_number_format($db->fetch_field($countadmins, "totaladmins")); 
		$countadmins2 = $db->write_query( "SELECT COUNT(*) AS totaladmins2 FROM ".TABLE_PREFIX."users WHERE `usergroup` = 8 " );
		$totaladmins2 = my_number_format($db->fetch_field($countadmins2, "totaladmins2")); 
		$countadmins3 = $db->write_query( "SELECT COUNT(*) AS totaladmins3 FROM ".TABLE_PREFIX."users WHERE `usergroup` = 9 " );
		$totaladmins3 = my_number_format($db->fetch_field($countadmins3, "totaladmins3")); 
$toplamad = $totaladmins + $totaladmins2 + $totaladmins3;
echo "<b>" . $toplamad . "</b>";
		?>