0
<?php



$per_page = 1;
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
$start = ($page - 1) * $per_page;
$totalcount = mysql_query("SELECT COUNT(DISTINCT user_id) FROM images");
$totalcountplus = ceil(mysql_result($totalcount, 0) / $per_page);
$totalcountone = mysql_query("SELECT DISTINCT `user_id` FROM `images` LIMIT $start, $per_page");
while($totalcountplusone = mysql_fetch_array($totalcountone))  {
$usercountone  =$totalcountplusone['0'];
}

?>

你好。我怀疑这是一个简单的解决方法,但我很难弄清楚到底该做什么。作为记录,这个脚本在 localhost 上运行良好,但我已经迁移到了一个实时服务器。

该脚本很简单——它设置了每页的项目数,然后使用 LIMIT sql 函数在正确的位置产生分页符。和以前一样,这在 localhost 上运行良好,但自从迁移它之后就不行了。它会创建正确数量的页面,但不会将正确数量的项目推送到每页上。

我怀疑这是问题所在:

$totalcountone = mysql_query("SELECT DISTINCT `user_id` FROM `images` LIMIT $start, $per_page");

事实证明,在我的服务器记事本上,脚本中的所有其他变量都是深绿色,而 $start 和 $per_page 都是亮蓝色。我尝试将这两个变量都包含在双引号和单引号中,但我不确定如何解决这个问题。非常令人沮丧。

另外:我刚刚将 $start 和 $per_page 替换为 1, 1 作为整数。这仍然不起作用,所以我现在完全不知所措,特别是当它在本地主机上工作时。我不确定上面的那一行是否是现在的问题。

欢迎所有建议。

4

1 回答 1

0

排队

$totalcountplus = ceil(mysql_result($totalcount, 0) / $per_page);

在初始化之前使用 $per_page

于 2013-11-06T20:49:23.797 回答