Jump to content

Archived

This topic is now archived and is closed to further replies.

rcharris

Date Order *SOLVED*

Recommended Posts

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
[quote]
                      <?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 />";
}
?>
      [/quote]

(obv. ive removed the db details :))

Thanks :)

Share this post


Link to post
Share on other sites
Perhaps change the ASC to DESC in your ORDER BY statement?

Share this post


Link to post
Share on other sites

×

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.