I'm using the following code to show a list of files. The files should be sorted by the most recent date.
Code: Select all
<?php
$recent = $site_class->data_get(db_productfiles,'','','pfile_date_created DESC','500');
$n=1;
$pout = array();
$monthlist = array ('01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December');
while (list($name, $value) = each($recent)) {
//foreach ($recent as $name => $value){
$time = $recent[$name]['pfile_date_created'];
list ($year,$month) = explode("-",$time);
$time = $month."-".$year;
if (empty($pout[$time])){
$pout[$time] = "<strong>".$monthlist[$month]."-".$year."</strong><br />";
}
$pout[$time] = $pout[$time]."<a href=\"PDF/Test_PDF/".$recent[$name]['pfile_file']."\"class=\"a\">".$recent[$name]['pfile_description']."</a> - ".$recent[$name]['pfile_type']." - ".$recent[$name]['pfile_size']."Kb<br />";
$n++;
}
krsort($pout);
foreach ($pout as $name => $value){
echo ucfirst($value)."<br />";
}
}
?>Could someone help me how to modify the code to sort by year and then month, so that January 2010 shows on top of the page?