iJoseph Posted January 3, 2010 Share Posted January 3, 2010 I have a piece of code that shows a news atricle from a mysql database, but I need to make it show so that the newest article is desplayed at the top. How would I go about doing this? Here is my code: <?php $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $result = mysql_query("SELECT * FROM news"); while($row = mysql_fetch_array($result)) { echo "Author: " . $row['author'] . "<br />"; echo $row['message'] . "<br /><br />"; } mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/187046-my-sql-select-ordering-help/ Share on other sites More sharing options...
premiso Posted January 3, 2010 Share Posted January 3, 2010 If you have a date field, order by that. SELECT * FROM new ORDER BY `date_field` Link to comment https://forums.phpfreaks.com/topic/187046-my-sql-select-ordering-help/#findComment-987765 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.