Jump to content

order by error...


jesushax

Recommended Posts

hi could somone tell me why this brings up a mysql error please

 

the error is

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDERBY NewsDateAdded DESC' at line 1

 

cheers

 

$max = 3; //amount of articles per page. change to what to want
$p = @$_GET['p'];
if(empty($p))
{
$p = 1;
}
$limits = ($p - 1) * $max; 

//view all the news articles in rows
$sql = mysql_query("SELECT * FROM tblNews LIMIT ".$limits.",".$max." ORDER BY NewsDateAdded DESC") or die(mysql_error());
//the total rows in the table
$totalres = mysql_result(mysql_query("SELECT COUNT(NewsID) AS tot FROM tblNews"),0);	
//the total number of pages (calculated result), math stuff...
$totalpages = ceil($totalres / $max); 
echo '<h3>News</h3>';
echo "<div style='text-align:center;'>View Page: ";
for($i = 1; $i <= $totalpages; $i++){ 
//this is the pagination link
echo "<a href='short_news.php?p=$i'>$i</a>|";
}
echo "</div>";
$i = 0;

Link to comment
https://forums.phpfreaks.com/topic/98167-order-by-error/
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.