simple(?) php question from noob
Permalink
so there's a line of code
but r_dt is in xx/xx/xxxx format, so it's ordering by month then day then year - so how do I change r_dt so it sorts from most recent to oldest? $ordering is set up for ASC or DESC preference.
$db->Query("SELECT * FROM btXXX ORDER BY r_dt $ordering, bID $ordering");
but r_dt is in xx/xx/xxxx format, so it's ordering by month then day then year - so how do I change r_dt so it sorts from most recent to oldest? $ordering is set up for ASC or DESC preference.
My suggestion is to change the data type of your db field to 'date' data type. Then you will be able to sort by the dates chronological order.
Also, I notice that you are sorting by two seperate columns 'r_dt' and 'bID', this may also be causing unexpected results. I assume that your variable $ordering is either 'ASC' or 'DESC', but if it is something else, this too could cause unexpected results.
Hope that helps.
Remember, if you change the data type for the r_dt column, you will have to make sure your update and insert queries format the date correctly (YYYY-MM-DD)