Hi
I am currently using the following code:
<?php
function test(){
$mytable="<TABLE><TR><TD>";
for ($j=12; $j>3; $j--) {
$sql = "SELECT URL, COUNT(*) FROM click WHERE MONTH(log_date) = '$j' && YEAR(log_date) = '2004' GROUP BY URL";
$result=mysql_query($sql);
$mytable = $mytable . "<TABLE BORDER='1' width='400'><TR><TD width='280'><b>Website</b></TD><TD width='120'><b>" . $j . "/2004 Totals</b></TD></TR>";
while($thisrow=mysql_fetch_row($result))
{
$i=0;
while ($i < mysql_num_fields($result))
{
$field_name=mysql_fetch_field($result, $i);
$k = $i + 1;
$mytable = $mytable . ("<TR><TD>" . $thisrow[$i] . "</TD><TD align='center'>" . $thisrow[$k] . "</TD></TR>");
$i = i + 2;
}
}
$mytable = $mytable . "</TABLE><BR><BR>";
}
$mytable = $mytable . "</TD></TR></TABLE>";
return $mytable;
}
$context ["stats"] = test();
?>
Which is doing exactly what I want it to do with the exception that I have to manually change the month & year (and in January I don't know how I will overcome the year issue!)
Is there a way of manipulating what I have so far to show stats from 04/2004 to the current month without me having to change the code manually?
Many Thanks