Saturday, 7 September 2013

I'm Having Problems With My Post System?

I'm Having Problems With My Post System?

I know the basics of MySQL and PHP. I've set up a posting system that
echos the fields from my table.
The only problem is, since this is a news page, the newest posts need to
be on top. And when the page echos back the results, it puts the first
entry I made (in the table) at the top.
This is my code:
// Selecting The Table
$result = mysql_query("SELECT * FROM posts")
or die(mysql_error());
// Connecting To The Rows, And Echoing Back The Results
while($row = mysql_fetch_array($result)){
echo "<div class='post'>";
echo "Title: " . $row['title'];
echo "<br />";
echo $row['content'];
echo "</div>";
I am not sure how to make the latest post the first to show up.
I still want it to echo back the older entries though.
I can use PHPMyAdmin if necessary.

No comments:

Post a Comment