Ik vind de eenvoudigste manier iets in de trant van:
$entries = array();
while ($row = mysql_fetch_assoc($sql)) {
$entries[$row['get_year']][] = $row;
}
foreach($entries as $year => $months) {
echo '<dl>';
echo '<dt>Entries from '. $year . '</dt>';
echo '<dd>';
foreach($months as $month) {\
$this_month = date( 'F', mktime(0, 0, 0, $row["get_month"]) );
echo '<a href="archives.php?month='. $month['get_month'] .'">Entries from '. $this_month . ' </a>(' . $month['entries'] . ')';
}
echo '</dd></dl>';
}
Die HTML-opmaak is niet ideaal, maar je zou het idee moeten krijgen.