pagination sql query syntax

mysql, pagination, sql, sql-order-by

Solution

Order by should go before limit:

$query = mysql_query("SELECT * FROM {$statement} 
ORDER BY datetime ASC LIMIT {$startpoint} , {$limit}");

Problem

I am trying to sort my posts in my discussion board by date. Here is my code: ``` $query = mysql_query("SELECT * FROM {$statement} LIMIT {$startpoint} , {$limit} ORDER BY datetime ASC"); ``` Is there anything syntactically wrong with this? If not, what else could be wrong? Basically what is happening, is that the results are not showing up. I remove the Order by, and it works (but of course it's not sorted...)

Original source