Reputation: 67
I have a basic upload and gallery view for photos. However, the view for the gallery is by oldest first.
Can someone show me an easy way for me to sort this by newest first? This is my PHP which shows the images:
<?php
$sql="SELECT * FROM chiseldonuploads";
$result_set=mysql_query($sql);
while($row=mysql_fetch_array($result_set));
{
?>
<img class="photos" src="uploads/<?php echo $row['file'] ?>"></td>
<?php
}
?>
Upvotes: 0
Views: 248
Reputation: 1942
In case your table chiseldonuploads has column date, for example created_date you can order it by date, or if it does not have date, you can try ordering by id of the table:
$sql="SELECT * FROM chiseldonuploads ORDER BY id DESC";
Here id has to be replaced with column name representing id column in your table. But if you have date column, you have to order by date.
Upvotes: 2