我想将此查询按ID降序排列。

我收到错误mysql_fetch_array() expects parameter 1

$checkquery = "SELECT COUNT(message), user, date_time FROM messages";
$collctmsg = mysql_query($checkquery, $db_connect);
$no_rows = mysql_fetch_row($collctmsg);
$numrows = $no_rows[0];
$rows_per_page = 5;
$lastpage = ceil($numrows/$rows_per_page);
$pageno = (int)$pageno;
if ($pageno > $lastpage) {
   $pageno < $lastpage;
} // if
if ($pageno < 1) {
   $pageno = 1;
} // if
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;

$messageshow = "SELECT message, user, date_time FROM messages {$limit}, ORDER BY id DESC";
$message_execution = mysql_query($messageshow, $db_connect);

最佳答案

最后限制,并且您的limit子句和order by子句之间没有逗号

SELECT message, user, date_time FROM messages ORDER BY id DESC {$limit}

关于php - 如何订购此查询?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9748562/

10-14 12:52