Jump to content

Sorting Results


Pawn

Recommended Posts

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.

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

[b]Edit2:[/b] 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?
Link to comment
Share on other sites

[code] $query = "SELECT whatever FROM wherever ORDER by date DESC";[/code]
depends on the date format you're using ... which is guess is yyyy-mm-dd so it's sortable without messing around
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.