Jeg har haft gjort således:
- SELECT *, COUNT(blogId) as antal FROM blog GROUP BY YEAR(blogDate), MONTH(blogDate) ORDER BY blogDate ASC
Der udskriver den
September 2008(1)
April 2012(1)
Maj 2012(3)
Efter at jeg har skrevet
- $db->mysql_open();
- mysql_set_charset('utf8');
- $db->query("SELECT *, COUNT(blogId) as antal FROM blog GROUP BY YEAR(blogDate), MONTH(blogDate) ORDER BY blogDate ASC");
- $result = $db->fetchAll();
- foreach($result as $row):
- $month = date("m", strtotime($row["blogDate"]));
- $year = date("Y", strtotime($row["blogDate"]));
-
- $months = array(01 => "januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december");
-
- $dateMonth = $months[intval($month)];
-
- echo '<li><a href="'.$menu->menu().'date/'.$month.'/'.$year.'/"><span style="float:left;">'.ucfirst($dateMonth).' '.$year.'</span> <span style="float:right;">('.$row["antal"].')</a></a></li>';
- endforeach;
Så forstår ikke hvorfor det ikke virker /: