MyBB Community Forums

Full Version: Countqueary Code Usage
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!

I have this code, to count members in a certain group, but I'm unsure how to use it.

I have the template conditionals and php in templates enabled, so I can do it in-template, or I can access the FTP.

I don't mind how, I would just greatly appreciate some information on how to activate the code, and have it print out the appropriate numbers.

$countquery = $db->fetch_field(
$db->query("
SELECT COUNT(*) as countquery
FROM ".TABLE_PREFIX."users
WHERE ".TABLE_PREFIX."users.usergroup IN (10)
"), 'countquery');


Thank you so much!
do you have to display it at a specific location ?

if you like to have a separate page then this might help : usergroup page
Hi .m.! I’d like to display it on the forum index with the online members area Smile
$countquery = (int)$db->fetch_field(
	$db->simple_select(
		'users',
		'COUNT(uid) AS countquery',
		"usergroup IN (10)"
	),
	'countquery'
);

$total_users = my_number_format($countquery);

Please note that users can have additional user groups in the additionalgroups column.
perhaps it would be better to use view groups plugin & add required variable to its display.

however at present can't install the plugin on a test board to look at it ...
@.m. - that's almost what I want. It adds a legend that can be clicked to view everyone in that group; ideally, i'd be looking to include the number on the front page, too.

I'd like to put in the Statistics area, something like;

24 members registered; 2 OOC, 17 Characters, 5 Pending

[Image: ca800079153f36839407d498a701feb2.png]