displaying data by order

hi all,
I have created a php page to display data from MYSQL DB, all works ok apart from i have done it in ORBER BY a column containgin a date (formatted dd/mm/yyyy). Now the column ulso has ‘TBA’ but it which is was is causing the problem. but excuting the SQL command below the data displays showing the rows first with TBA in them followed by the rows (in date order) containing the dates.

what i need it to do is to display the rows with dates in the date field first (in order) before displaying the rows that contain TBA in the date field.

here is my SQL statement.
$sql=“SELECT * FROM $tbl_name WHERE status = ‘active’ ORDER BY STR_TO_DATE(Date, ‘%d/%m/%y’) ASC,time ASC”;

I have tried to ORDER BY DESC which puts the dates before the TBA but the dates are not in the correct order.

any help will be very much appreciated.

Clive Taylor

If you want dates to be in order, perhaps you should do them in yyyy/mm/dd format.

$sql=“SELECT * FROM $tbl_name WHERE status = ‘active’ ORDER BY STR_TO_DATE(Date, ‘%y/%m/%d’) ASC,time ASC”;

Try this or a variation of it.

Sponsor our Newsletter | Privacy Policy | Terms of Service