Ok, say I have some news articles that are displayed using mySQL and PHP.
When I add a new article, the newer one goes at the bottom. How do I make it so the newer one displays at the top.

Ok, say I have some news articles that are displayed using mySQL and PHP.
When I add a new article, the newer one goes at the bottom. How do I make it so the newer one displays at the top.
PHP Code:ORDER BY `lol` DESC
what do I replace with 'lol'?
And if you want it to display only 5 then:
PHP Code:SELECT * FROM `news` ORDER BY `id` DESC LIMIT 0 , 5
Last edited by Moh; 14-02-2008 at 11:43 PM.
Gosh I'm a nub.
Where would I add that in this:
NVM: Got it. Thank you Simon and Jack.PHP Code:<?php
include "config.php";
$sql = "SELECT * FROM news";
$check = mysql_query("SELECT authour, title, news_content, date FROM news") or die("There is no news at the moment.");
while ($display = mysql_fetch_array($check)) {
$news_content = $display['news_content'];
$title = $display['title'];
$authour = $display['authour'];
$date = $display['date'];
echo "<h2>$title - <span>by $authour</span></h2>
<p>$news_content<br />
<strong><i>Posted on: $date</i></strong></p><br />
<br />
";
}
?>
Last edited by loserWILL; 14-02-2008 at 11:48 PM.
Egh, the "DESC LIMIT 0 , 5" is causing me problems:
The firts news title is fine, but the second news article's title is shifted to the right When I removed that desc limit it's fine, but it doesn't order the news how I want it to.
[quote=loserWILL;4447420]Gosh I'm a nub.
$sql = "SELECT * FROM news";
What the hell do you keep putting that in there for it serves no purpose.
visit my internet web site on the internet
http://dong.engineer/
it is just videos by bill wurtz videos you have been warned
I'll remove that.
Does anybody know the answer to the question I posted above?
The `id` is what its ordering by.PHP Code:SELECT * FROM `news` ORDER BY `news`.`id` ASC LIMIT 0 , 5
That doesn't order it properly, or at leats how I want it to order.
Want to hide these adverts? Register an account for free!