Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 2 Years, 10 Months, 3 Weeks ago Total Members of Group / Total Threads in FID
#1
Solved: 2 Years, 10 Months, 3 Weeks ago
Alright so I have made a thread in the past - link - I've ran into some issues along the ways. I've ran various MyBB SQL Queries and yet to no avail. Perhaps what I'm needing is a clean mind but I'm exhausted and getting rather annoyed. Any suggestions or results would be awesome in this case.


Problem Number One
Okay so for example I have a total of 5 administrators on my board.
I want to display the total members in each group like such.
Very similar to the overall forum statistics.

[Image: c7d303773032d4b1a76807c02bd45990.png]




Problem Number Two
Okay so for example I have a total of 3,000 threads in Forum ID 2.
I want to display the total threads in that Forum ID.
Very similar to the overall forum statistics.

[Image: d72a00b66dfc41ffef76292a51132e54.png]
Check out all my submissions here - click me
MyBB support at it's finest. 
Reply
#2
Solved: 2 Years, 10 Months, 3 Weeks ago
The first one gets ugly if you are considering secondary usergroups. It gets to be very server intensive based on how many members you have. If you are only using primary groups you could do something like this:

$usergroupsquery = $db->simple_select("usergroups", "gid,title");
echo "<table><tr><th>Usergroup</th><th>Number of Users</th></tr>";
while($usergroup = $db->fetch_array($usergroupsquery))
{
$usercountquery = $db->simple_select("users", "COUNT(uid) as total", "usergroup=" . $uisergroup['gid']);
$count = $db->fetch_field($usercountquery, "total");
echo "<tr><td>" . $usergroup['title'] . "</td><td>" . $count . "</td></tr>";
}
echo "</table>";

I purposely avoided querying the user table only because otherwise you'd have to select the usergroup for each member and run it through a loop in php to get counts. That would lead to much more server intensive process.

The second problem can be handled similar to the first except you will first query the forums table and then the threads table.
Reply
#3
Solved: 2 Years, 10 Months, 3 Weeks ago
(11-26-2016, 02:07 PM)dragonexpert Wrote: -snip

I managed to get the code reduced down to 2 lines. Thanks for the help. Before the output kept coming up blank but now I see where I was going wrong. Thanks dude.
Check out all my submissions here - click me
MyBB support at it's finest. 
Reply
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)