Jump to content


Photo

Date Order *SOLVED*


  • Please log in to reply
2 replies to this topic

#1 rcharris

rcharris
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 23 October 2006 - 09:04 AM

Hi all,

Something I;ve never done here before, so any help would be appreciated, if you have time please :)

I've got the following code, and basically, I want to order a manually entered in date (mm/dd/yyyy with the latest date at the top and the furthest away at the bottom

                      <?php

// Connect to the database server
$dbcnx = @mysql_connect('n/a', 'n/a', 'n/a');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
    'database server at this time.</p>');
}

// Select teh portfolio database
if (!@mysql_select_db('n/a')) {
exit('<p>Unable to locate the portfolio ' .
    'database at this time.</p>');
}

// Request the text of all the news stories
$result = @mysql_query('SELECT title, id, content,date1, updated, url, picturename FROM news ORDER BY date1 ASC');
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}

// Display the text of each joke in a paragraph
while ($row = mysql_fetch_array($result)) {
    echo "{$row['date1']}<br /><a href=\"newsstory.php?story={$row['id']}\" class='noba_10_news_nav'>{$row['title']}</a><br /><img src='images/whiteline_154.gif' width='154' height='9'><br />";
}
?>
     


(obv. ive removed the db details :))

Thanks :)

#2 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 23 October 2006 - 10:08 AM

Perhaps change the ASC to DESC in your ORDER BY statement?

#3 rcharris

rcharris
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 23 October 2006 - 12:52 PM

Ahh! It works, THANK YOU =D

Made my day ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users