PDA

View Full Version : How to exclude usergroups condition


vexxy
10-26-2011, 06:38 AM
I have the following stats code from the widget that displays the total number of users etc. unfortunately, it shows all users, including the ones from waiting for confirmation etc.

What's the condition to exclude them from usergroups 3 and 4?

ob_start();
global $vbulletin, $db, $vbphrase;
//Begin Forum Stats
// forum stats start
$numbersmembers = $db->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM " . TABLE_PREFIX . "user");
$numbermembers = number_format($numbersmembers['users']);
$counter = $db->query_first("SELECT COUNT(postid) AS posts, COUNT(threadid) AS threads FROM " . TABLE_PREFIX . "post");
$totalposts=number_format($counter['posts']);
$countthreads = $db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread");
$totalthreads=number_format($countthreads['threads']);
// forum stats end

--------------- Added 1319662936 at 1319662936 ---------------

nobody can help me?

vexxy
10-27-2011, 03:20 PM
soo..any help pls? :)

Lynne
10-27-2011, 05:07 PM
How about replacing this:
$numbersmembers = $db->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM " . TABLE_PREFIX . "user");


with
$numbersmembers = $db->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM " . TABLE_PREFIX . "user WHERE usergroupid NOT IN (3,4)");

vexxy
10-27-2011, 06:27 PM
tnx alot Lynne, wonderful as always

Christos Teriakis
10-29-2011, 04:57 AM
In addition to Lynne's advice which is 100% correct, I'm extending the query in case that you want the usergroupid to not exists even in the additional usergroups. You must add in the query:

AND NOT FIND_IN_SET($usergroupid, membergroupids)


Chris