Question: order of mysql query changes after the query


order of mysql query changes after the query

Answers 1
Added at 2017-01-01 20:01

when I make the Query

SELECT * FROM roadtrips
ORDER BY start_date DESC, 
         username DESC;

I get the results ordered in the way I want. But when I change the format of the "start_date" (wich has type: date) with the php function date("d.m.Y",$date) while I am fetching the data out of my result with a while loop I suddenly get a different ordering:

An example:

while ( $row = mysqli_fetch_assoc($result))

suddenly the dates are not orderes at all?! How can that be since I am changing the format of "start_date" after the request has been made?

nr: #1 dodano: 2017-01-01 21:01

I tried $date=strtotime('4002-04-03') and the return is FALSE. So it failed there.

Just use mysql with:

SELECT DATE_FORMAT(date, '%d.%m.%Y')

and make the ordering there so you don't need to change to strtotime.

Source Show
◀ Wstecz