Reputation: 588
I need the results to show the most recent first - at the moment this code shows the updates in chronological order. Unfortunately I don't have access to the query in the below code so I need to run this within the code shown. Any ideas?
<?php
if($updates)
{
foreach($updates as $up)
{
?>
<li class="common_li" style="background:none; border:none; padding:0px;">
<p style="font-size:12px; font-weight:nornal; font-style:italic; color:#999999;">
<?php echo date($site_setting['date_format'],strtotime($up['date_added'])); ?></p>
<div style="border-radius:8px 8px 8px 8px;" class="detail_update">
<?php echo $up['updates'] ; ?></div>
</li>
?>
Upvotes: 0
Views: 69
Reputation: 33153
You need to find out where the $updates
variable is coming from and change the query there.
Another option is to sort the variable by the date_added
key:
function sort_by_date( $a, $b ) {
return strtotime( $a[ 'date_added' ] ) - strtotime( $b[ 'date_added' ] );
}
usort( $updates, "sort_by_date" );
Changing the query is the cleaner way, so I recommend doing that if at all possible.
Upvotes: 2