blurd Posted August 15, 2006 Share Posted August 15, 2006 I'm making a news script for my site and everything works, like i have the script reading the data from the database and everything. BUT, every time i add new news, it gets put under the old ones and i want it on top. Here is my script and thanks to anyone who helps.[CODE]<?phpinclude 'config.php';include 'opendb.php';$query = "SELECT Username,Date,Time,Title,Content FROM news";$result = mysql_query($query);while($row = mysql_fetch_array($result, MYSQL_ASSOC)){echo "<TABLE WIDTH='100%' BORDER=0 CELLPADDING=2 CELLSPACING=0><TR style='text-align:center;vertical-align:middle;font-size:12pt;font-weight:bold;'><TD width='15%' style='font-size:10pt;border-left:1px solid black;border-bottom:1px solid black;border-top:1px solid black;'>$row[Date] At $row[Time] </TD><TD width='70%' style='border-top:1px solid black;border-bottom:1px solid black;'> $row[Title] </TD><TD width='15%' style='font-size:10pt;border-right:1px solid black;border-bottom:1px solid black;border-top:1px solid black;'> By: $row[Username]</TD></TR><TR style='text-align:center;vertical-align:middle;font-size:10pt;'><TD width='15%' style='border-left:1px solid black;border-bottom:1px solid black;'> </TD><TD width='70%' style='border-bottom:1px solid black;'> $row[Content] </TD><TD width='15%' style='border-right:1px solid black;border-bottom:1px solid black;'> </TD></TR></TABLE><BR>";} include 'closedb.php';?> [/CODE] Quote Link to comment Share on other sites More sharing options...
yarub Posted August 15, 2006 Share Posted August 15, 2006 $query = "SELECT Username,Date,Time,Title,Content FROM news ORDER BY Time DESC";Replace Time with whatever field you want to order it by. Descending will make it so the newer posts will show first. Quote Link to comment Share on other sites More sharing options...
blurd Posted August 15, 2006 Author Share Posted August 15, 2006 Thanks Man, Exactly what i needed :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.