Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/members/saaceadmin/
Upload File :
Current File : /var/www/cesa.co.za/members/saaceadmin/graph.phtml

<?php
include('../inc/conf.inc');
include('../inc/db.inc');
//$sql = "select * from user_login WHERE TO_DAYS(NOW()) - TO_DAYS(registered) <=30 ORDER BY registered DESC";
$sql = "select * from user_login ORDER BY registered DESC";
$result=mysql_query($sql);
$num_rows = mysql_num_rows($result);

function GetPercent($iPerDay, $iTotal)
{
	$percent = round(($iPerDay / $iTotal) * 100);
	return $percent;
} //end function

function GetPartOfDate($sAnyDate, $iLength)
{
	for ($i = 0; $i <= $iLength; $i++)
	{
		$sNewDate .= $sAnyDate[$i];
	} //end for
	return $sNewDate;
} //end function

$test=0;
$counter=0;
$wtf = 0;

while ($row=mysql_fetch_array($result)) {
	if ($test == 0) {
		$test++;
		$sCompareDate = GetPartOfDate($row["registered"], 10);
	} //end if

	if (eregi($sCompareDate, $row["registered"])) {
		$counter++;
		$arr[$sCompareDate] = $counter;
	}
	else
	{
		$arr[$sCompareDate] = $counter;
		$counter = 1;
		$sCompareDate = GetPartOfDate($row["registered"], 10);
	} //end if else
	$wtf++;
	if ($wtf == $num_rows)
	{
		$sCompareDate = GetPartOfDate($row["registered"], 10);
		$arr[$sCompareDate] = $counter;
	}
	//printf('Date: %s, Compare: %s, Total: %s<br>', $row["registered"], $sCompareDate, $counter);
}
?>
<h3>Number of users registered per day for the last 30 days</h3>
<p>Where no users registered, there is no row for that day</p>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<?php
while (list ($key, $val) = each ($arr)) {
	$per = GetPercent($val, $num_rows);
	$width = $per * 5;
	printf('<tr><td>%s</td><td width="125"><img src="../pics/graph.jpg" width="%s" height="10" alt="%s percent users registered"></td><td align="right">%s user registered</td></tr>', $key, $width, $per, $val);
}
?>
<tr><td colspan="3" align="right">&nbsp;</td></tr>
</table>
<?php
echo "<a href=\"/saaceadmin/\">Back to SAACE Admin</a>";
mysql_close($conxan);
?>