Reputation: 142
I'm trying to run this query:
$query = "SELECT * FROM `official_holiday` ORDER BY `official_holiday`.`date` desc";
I even generated the query with PHPMyAdmin just to be sure its correct. I dont why it does not order at all and just takes the dates as they are in the DB.
How can I order by date? I just want to echo the results with the smallest date first from the fetched result array.
Thanks in advance
Upvotes: 0
Views: 44
Reputation: 1531
SELECT * FROM `official_holiday` ORDER BY date DESC.
This should work, as long as your dates are stored in the correct format.
Nice and simple.
Upvotes: 0
Reputation: 11987
Change your query like this
SELECT * FROM `official_holiday` ORDER BY DATE(`official_holiday`.`date`) desc.
It will work fine.
Upvotes: 1