BrighteyesDesign
asked on
Show archive DESC from date and add link
I have an archive function working on my Blog using the following code...
How can I get the dates to show the other way round? ie 2012 first.
Also how would add a link? I need to send a link to the detail page which will show posts from that year & month.
Screen-shot-2012-03-31-at-16.02..png
mysql_select_db($database_acsinfo, $acsinfo);
$query_archive = "SELECT YEAR(`eventdate`) AS 'year', MONTH(`eventdate`) AS 'month', COUNT(`id`) AS 'count' FROM `latestnews` GROUP BY YEAR(`eventdate`), MONTH(`eventdate`) DESC
";
$result = mysql_query($query_archive, $acsinfo) or die(mysql_error());
$data = array();
while($row = mysql_fetch_assoc($result)) {
if( intval($row['count']) >0) $data[$row['year']][$row['month']] = $row['count'];
}
<?php foreach ($data as $year => $months) {
echo $year.'';
foreach ($months as $month => $count) {
echo date("F", mktime(0,0,0,$month,1,2000)).'('.$count.')<br>';
}
} ?>
How can I get the dates to show the other way round? ie 2012 first.
Also how would add a link? I need to send a link to the detail page which will show posts from that year & month.
Screen-shot-2012-03-31-at-16.02..png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Anyone know how to do this?
ASKER
Where would I add a link around the results so you click on 'July (1)' for example, it takes you a page with the month in the URL to display posts from that month?
I have tried...
Open in new window