Jump to content


Photo

Sorting Results


  • Please log in to reply
1 reply to this topic

#1 Pawn

Pawn
  • Members
  • PipPipPip
  • Advanced Member
  • 126 posts
  • LocationEngland

Posted 02 May 2006 - 02:44 PM

This question must have been asked before, but my inept use of the search function can't seem to find an appropriate answer. Feel free to answer with a link.

I'm displaying MySQL table results using a while loop to generate news on my homepage, [a href=\"http://www.superlatenight.com\" target=\"_blank\"]superlatenight.com[/a]. Currently rows display in the order which they were added. Of course, I'd like the most recent news to display first. How's this done?

Thanks in advance.

Edit: So yeah I'm a moron. ORDER BY. Sorry for the time wasting.

Edit2: Do I need to make the field DATETIME in order to correctly sort two news entries posted on the same date? Considering I won't want the output in its default 0000:00:00 0000:00:00 (I prefer the English DD-MM-YY), am I better off using a less specific column type?
Freelance PHP Developer
http://brickmedialab.com

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 02 May 2006 - 02:50 PM

$query = "SELECT whatever FROM wherever ORDER by date DESC";
depends on the date format you're using ... which is guess is yyyy-mm-dd so it's sortable without messing around
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users