Jump to content

MY SQL select ordering help


iJoseph

Recommended Posts

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

Archived

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

×
×
  • Create New...

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.