Results 1 to 3 of 3

Thread: Order by date

  1. #1
    Join Date
    Aug 2009
    Location
    Florida
    Posts
    23
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Order by date

    I have been playing with this photo album script for a while and it works just fine but I'm having problems ordering the pictures by the date. I have one page that displays all the thumbnails and since the new year it's all out of order.. I've tried a couple of things but, I'm still pretty green and I can't figure it out. I would like for it to display all the pics starting with the most recent pictures to the oldest.

    Thanks in advance for your help!

    PHP Code:
    <?

    //////// My query that is probably all screwed up


    $sql mysql_query("SELECT * FROM photo_album ORDER BY pmonth desc, pday desc, pyear desc");

    echo 
    '<table align=center>';
    // Check to see if any results were returned
    if(mysql_num_rows($sql) > 0){
        echo 
    '<tr>';
        
    // Loop through the results
        
    while($row mysql_fetch_array($sql)){
            echo 
    'Bla Bla Bla Bla';



    ?>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,982
    Thanks
    43
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    Try:

    Code:
    $sql = mysql_query("SELECT * FROM photo_album ORDER BY pyear desc, pmonth desc, pday desc");
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    captainjustin (01-10-2011)

  4. #3
    Join Date
    Aug 2009
    Location
    Florida
    Posts
    23
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Ok I figured it out.... My picture dates were listed like so 1/15/2010 so I changed the date to read like so 01/15/2010 ....... That and order by pyear desc first ..... Thanks for your help John

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
  •