我大致按照这个链接创建了一个分页:
http://www.awcore.com/dev/1/3/Create-Awesome-PHPMYSQL-Pagination_en#toggle
很酷。虽然我的查询有问题。
它像这样工作正常:
require 'includes/function.php';
$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$limit = 8;
$startpoint = ($page * $limit) - $limit;
$statement = "cars WHERE deleted = 'no'";
$query = mysql_query("SELECT * FROM {$statement} LIMIT {$startpoint}, {$limit} ");
while ($row = mysql_fetch_assoc($query)) {
但是,当我尝试向其中添加 ORDER BY 时,如下所示:
需要'includes/function.php';
$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$limit = 8;
$startpoint = ($page * $limit) - $limit;
$statement = "cars WHERE deleted = 'no'";
$query = mysql_query("SELECT * FROM {$statement} LIMIT {$startpoint}, {$limit} ORDER BY model DESC");
while ($row = mysql_fetch_assoc($query)) {
或者只是像这样更改语句:
$statement = "rcr_cars WHERE deleted = 'no' ORDER BY model DESC";
我收到此错误:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in filepath/myfile.php on line 79.
第 79 行是这一行:
while ($row = mysql_fetch_assoc($query)) {
谁能告诉我我如何没有正确使用 ORDER BY,这让我很困惑。:/