Forums

Sorting Descending or Ascending

djrobbie 27 Aug, 2010
Hello!

All my new database records display the oldest first in the html page. How can i make the sorting of the records by newest at the top ?
GreyHead 27 Aug, 2010
Hi djrobbie,

Put `recordtime` DESC in the Order fields box.

Bob
djrobbie 27 Aug, 2010
Then i get this:

Warning: Invalid argument supplied for foreach() in XXX /components/com_chronoconnectivity/libraries/connection.php on line 300
GreyHead 27 Aug, 2010
Hi djrobbie,

It's a warning, not an error; but do your results sort correctly?

If not do you have a recordtime column in the table?

Do you see any results without the ORDER entry?

Bob
status260 19 Jan, 2012
I have tried the above suggested method.

I've tried 'logDate' ASC and 'logDate' DESC but the order is not changing.

My goal was to display the newest entry first.
GreyHead 19 Jan, 2012
Hi status260,

They should be back-ticks `` round the column name not straight quotes. Please try `logDate` ASC

Bob
status260 19 Jan, 2012
Yes Greyhead the back ticks was the problem. I was unaware that it made a difference...
GreyHead 20 Jan, 2012
Hi status260.

MySQL uses straight quotes for text strings and back-ticks for column and table names.

Bob
status260 21 Jan, 2012
Thank you kindly for the education.
This topic is locked and no more replies can be posted.