2006-06-01, 07:18 PM
Pages: 1 2
2006-06-01, 08:40 PM
You could do it like this:
The variable $member_num would give you the number of members.
$query = mysql_query("SELECT * FROM ".TABLE_PREFIX."users");
$member_num = mysql_num_rows($query);
The variable $member_num would give you the number of members.
2006-06-02, 06:16 PM
DrPoodle Wrote:You could do it like this:
$query = mysql_query("SELECT * FROM ".TABLE_PREFIX."users"); $member_num = mysql_num_rows($query);
The variable $member_num would give you the number of members.
More efficient would be:
$query = mysql_query("SELECT COUNT(*) as total FROM mybb_users");
$temp = mysql_fetch_array($query);
$member_num = $temp['total'];
2006-06-02, 06:43 PM
Shouldn't this be in code modification?
2006-06-02, 11:41 PM
DennisTT Wrote:what if the prefix wasn't "mybb_" though...DrPoodle Wrote:You could do it like this:
$query = mysql_query("SELECT * FROM ".TABLE_PREFIX."users"); $member_num = mysql_num_rows($query);
The variable $member_num would give you the number of members.
More efficient would be:
$query = mysql_query("SELECT COUNT(*) as total FROM mybb_users"); $temp = mysql_fetch_array($query); $member_num = $temp['total'];
2006-06-02, 11:51 PM
Then you change it to ".TABLE_PREFIX."
Still if it were to be included inside mybb files you should use the mysql class, and if it is not. TABLE_PREFIX won't be valid anyways.
Still if it were to be included inside mybb files you should use the mysql class, and if it is not. TABLE_PREFIX won't be valid anyways.
2006-06-03, 12:27 AM
Is there anyway to make this also return the name of the newest member as well?
EDIT:
The number of users online on the forums may also be handy
EDIT:
The number of users online on the forums may also be handy
2006-06-03, 12:35 AM
Sure.
$query = mysql_query("SELECT * FROM ".TABLE_PREFIX."users" ORDER BY uid DESC LIMIT 0,1);
$array = mysql_fetch_array($query);
$newest_member = $array['username'];
2006-06-03, 12:51 AM
DrPoodle Wrote:Sure.Thanks, does that just show the newest member? If so what about the online users?
$query = mysql_query("SELECT * FROM ".TABLE_PREFIX."users" ORDER BY uid DESC LIMIT 0,1); $array = mysql_fetch_array($query); $newest_member = $array['username'];
2006-06-03, 12:56 AM
CraKteR Wrote:Still if it were to be included inside mybb files you should use the mysql class, and if it is not. TABLE_PREFIX won't be valid anyways.
That's exactly why I used mybb_ instead of TABLE_PREFIX as you had used mysql_query, I assumed you were giving code for use on pages where the MyBB global.php is not included.
However, if global.php is included, you can easily retrieve the statistics and the newest member using the cache.
Pages: 1 2