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
Change your query like this
SELECT * FROM `official_holiday` ORDER BY DATE(`official_holiday`.`date`) desc.
It will work fine.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.