Total users registered.

Started by envoy, July 17, 2005, 03:45:17 PM

Previous topic - Next topic

envoy

I just threw this together, thought you guys could possibly used iton your site, maybe someone can form it into a calendar like thing where you click the date and it shows you the number of registered users that day. You can set the amount of days to go back in the $nday variable. This was based off of a module for phpbb from hxxp:opentools.de [nonactive]


<?
require("Settings.php");
$connection=MYSQL_CONNECT($db_server, $db_user, $db_passwd) OR DIE("Unable to connect to database");
@mysql_select_db("$db_name") or die( "Unable to select database");
// set the below variable to how many days you want to see
// example for the last 5 days would be
// $nday = 5;
$nday = 30;

// SQL Query, don't touch unless you know what you are doing.
$sql = 'SELECT DAYOFMONTH(FROM_UNIXTIME(dateRegistered)) as day, MONTH(FROM_UNIXTIME(dateRegistered)) as mon,  YEAR(FROM_UNIXTIME(dateRegistered)) as year,COUNT(*) AS ant
FROM '.$db_prefix.'members
GROUP BY year,mon,day
ORDER BY year DESC, mon DESC, day DESC
LIMIT 0,'. $nday;

$query = mysql_query($sql);
$users_count = mysql_numrows($query);
$avg=0;
?>
<table width="25%" cellspacing="0" cellpadding="0">
<tr>
<th align="left">Month</th>
<th align="left">Day</th>
<th align="left">Year</th>
<th align="left">Registered</th>
</tr>
<?
for($n=0;$n<$users_count;$n++)
{
$users_data = mysql_fetch_array($query);
$mon = $users_data[mon];
echo "<tr><td>".getMonth($mon)."</td><td>".$users_data[day]."</td><td>".$users_data[year]."</td><td>".$users_data[ant]."</td></tr>";
$avg = $avg+$users_data[ant];
}
echo "<tr><td>Registered:</td><td></td><td></td><td> ".round($avg/$nday,2)."</td></tr></table>";

// function, maybe there is a better/more efficient way of doing this?
function getMonth($mon) {
if ($mon == 1) { $date_mod = "January"; }
elseif ($mon == 2) { $date_mod = "February"; }
elseif ($mon == 3) { $date_mod = "March"; }
elseif ($mon == 4) { $date_mod = "April"; }
elseif ($mon == 5) { $date_mod = "May"; }
elseif ($mon == 6) { $date_mod = "June"; }
elseif ($mon == 7) { $date_mod = "July"; }
elseif ($mon == 8) { $date_mod = "August"; }
elseif ($mon == 9) { $date_mod = "September"; }
elseif ($mon == 10) { $date_mod = "October"; }
elseif ($mon == 11) { $date_mod = "November"; }
elseif ($mon == 12) { $date_mod = "December"; }
return $date_mod;
}
?>

hxxp:www.ptlovers.com [nonactive] :: hxxp:www.smcars.net/ [nonactive] :: hxxp:www.dodgefans.com/ [nonactive]

[Unknown]


envoy

Well I just did this so someone can put it on there main page if needed, I wasn't sure if you could do that with the stats page if it was included in the SSI.php file.
hxxp:www.ptlovers.com [nonactive] :: hxxp:www.smcars.net/ [nonactive] :: hxxp:www.dodgefans.com/ [nonactive]

Advertisement: