SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Sorting

  1. #1
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sorting

    Is there a way to sort the entries in the database by date. I use curdate(); to enter the date.

  2. #2
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First off, there's no mention of curdate() on php.net. Is that a custom made function?

    and if your storing the date as a date/time field, you can sort them when you pull the record from your database.
    and example query would look like this:
    Code:
    SELECT * from tablename order by column_name ASC
    Where tablename is the table you want to get it from and column_name is the column that you want to sort by. ASC is ascending order, and DESC would sort it by descending order.

    Though i'd need to know the specifics to make this work.
    Like the type of the field, how the date is being stored etc.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Defender1
    First off, there's no mention of curdate() on php.net. Is that a custom made function?
    Curdate() is a MySQL function to return today's date

    More info here:
    http://www.mysql.com/doc/D/a/Date_an...functions.html

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thx defender. It worked perfectly.


Bookmarks

Posting Permissions

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