News pulisher, id list.

A

Anonymous

Guest
Try just adding an order by at the end of your sql statement:

SELECT * FROM news ORDER BY id DESC

or

SELECT * FROM news ORDER BY id ASC

-- depending if you want your data in ascending or decending order.
 
This is assuming your auto_increment field is named 'id' and you want it in ascending order. If you want it in decending, just change it to DESC, and if your auto_increment field is not 'id', just change 'id' to what the field name is.

Code:
mysql_connect('address','username','password');
    // login into the mysql database server
mysql_select_db('database');
    // select the site's database
$query = mysql_query('SELECT * FROM news ORDER BY id ASC');
    // get all the news in the 'news' table
while($news = mysql_fetch_array($query)) {
    echo "Title: " . $news['title'] . "<br />";
    echo $news['text'] . "<br />";
    echo "Posted by: " .$news['poster'] . "<br />";
    echo "---------------------<br />";
}
 
hehe...no thanks, all is good.

If that didn't fix the sort issue, just post back and we'll take another look at it.

good luck
 
Back
Top