I have a news system in my website. But every time I create some news it gets posted in the bottom of the last news. I was wondering what can I do so the newest news go on top of the older ones. Here's my code.. $getnews = "SELECT * FROM news"; $News = mysql_query($getnews) or die(mysql_error()); while($echo_news = mysql_fetch_array($News)) { $id = $echo_news["id"]; $title = $echo_news["title"]; echo "<div class=\"maintop\">"; echo "<div class=\"date\">" . $echo_news["newsdate"] . "</div><div class=\"maintitle\"><center>"; echo "<a href=\"?pg=article&id=$id \">$title</a>" . "</center></div></div>"; echo "\n<div class=\"mainContent\">\n<p>"; echo $echo_news["news"] . "\n<a href=\"admin/news/delete.php?t=".rawurlencode($title)."&id=$id\" class=\"delete\">Delete</a>\n</p></div>\n"; } PHP: If you need my Msql table ask me and I'll post it. Thanks in advance for any help.
Try this: $getnews = "SELECT * FROM news ORDER BY getnews DESC"; $News = mysql_query($getnews) or die(mysql_error()); while($echo_news = mysql_fetch_array($News)) { $id = $echo_news["id"]; $title = $echo_news["title"]; echo "<div class=\"maintop\">"; echo "<div class=\"date\">" . $echo_news["newsdate"] . "</div><div class=\"maintitle\"><center>"; echo "<a href=\"?pg=article&id=$id \">$title</a>" . "</center></div></div>"; echo "\n<div class=\"mainContent\">\n<p>"; echo $echo_news["news"] . "\n<a href=\"admin/news/delete.php?t=".rawurlencode($title)."&id=$id\" class=\"delete\">Delete</a>\n</p></div>\n"; } PHP: If that doesn't work, try ASC instead of DESC in the first line.