我想按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);
答案 0 :(得分:2)
这是使用ORDER BY子句完成的:
SELECT message, user, date_time FROM messages ORDER BY id DESC
答案 1 :(得分:1)
更新您的查询。限制后无需昏迷:
$messageshow = "SELECT message, user, date_time FROM messages {$limit} ORDER BY id DESC";
答案 2 :(得分:1)
限制最后一个,并且在您的限制条款和按顺序
之间没有逗号SELECT message, user, date_time FROM messages ORDER BY id DESC {$limit}