Hi
I have a table of the following data:
UID, URL, Logdate
1, www.foo.com, 2004-11-28
2, www.bar.com, 2004-11-27
3, www.foo.com, 2004-11-28
4, www.foo.com, 2004-10-08
etc
I have managed to scrape together the following code:
$sql = "SELECT URL, COUNT(*) FROM click WHERE log_date='2004-11-28' GROUP BY URL";
$result=mysql_query($sql);
echo "<TABLE BORDER='1'>";
while($thisrow=mysql_fetch_row($result))
{
$i=0;
while ($i < mysql_num_fields($result))
{
$field_name=mysql_fetch_field($result, $i);
$j = $i + 1;
echo "<TR><TD>" . $thisrow[$i] . "</TD><TD>" . $thisrow[$j] . "</TD></TR>";
$i = i + 2;
}
}
echo "</TABLE>";
I need to change the above, so that instead of a total count of URLs in the entire table is created, a table based on the month of the log date is created instead.
Something like:
URL October-04 November-04
www.foo.com 1 2
www.bar.com 0 1
I am very new to this and cannot understand how I change the code to pick up the month of the date - should it be done by GROUPING in the SQL?
Any help would be greatly appreciated.