Jump to content

Member Count Function


brown2005

Recommended Posts

function MembersCount()
{

$MembersCountSql = mysql_query("SELECT * FROM members WHERE members_activated='1';");
$MembersCountRows = mysql_num_rows($MembersCountSql);

$MembersCountRows = number_format($MembersCountRows);

return $MembersCountRows;

}

Is there any better way to write the above?
Link to comment
https://forums.phpfreaks.com/topic/30748-member-count-function/
Share on other sites

[code]
<?php
function membersCount() {
  $count = mysql_result(mysql_query("SELECT COUNT(*) AS count FROM members WHERE members_activated = '1'"), 0, 'count');
  return $count;
}
?>
[/code]

That should work... try to let MySQL do the crunching for you.
Link to comment
https://forums.phpfreaks.com/topic/30748-member-count-function/#findComment-141724
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.