Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2005
    Location
    UK
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Sorting data recieved from a databse

    Hi

    I have several records in a database that hold information about events. Each of these has a date field.

    What i want to do is be able to sort the data by the date field when i retrieve it from the database, so i can display it in order on my page ie. most recent at the top.

    I have the data being retrieved from the database successfully, and just being displaying in no order, but i dont know how to sort the data.

    Any suggestions?

    Many Thanks.
    Andrew,
    AKA ItsMe

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Code:
    SELECT * FROM `table` WHERE 1 ORDER BY `datefield` DESC

  • #3
    New Coder
    Join Date
    Mar 2005
    Location
    UK
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I thouht it'd be something like that.

    Many thanks for your reply.
    Andrew,
    AKA ItsMe

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    You're very welcome. =D


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •