好的,我有一个基本的 php 分页脚本,它有一个基本的下一个和上一个按钮。现在这工作正常,直到我添加一个不同的子句。请看下面的代码。
$query = "SELECT COUNT(*) as num FROM $tableName WHERE engine='$type' AND manufacturer='$man' AND '$year' BETWEEN start_year AND end_year";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages['num'];
echo "$total_pages";
$stages = 3;
$page = mysql_escape_string($_GET['page']);
if($page){
$start = ($page - 1) * $limit;
}else{
$start = 0;
}
// Get page data
$query1 = "SELECT Distinct model_group from $tableName WHERE engine='$type' AND manufacturer='$man' AND '$year' BETWEEN start_year AND end_year LIMIT $start, $limit";
$result = mysql_query($query1);
// Initial page num setup
if ($page == 0){$page = 1;}
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$LastPagem1 = $lastpage - 1;
现在,如果我将查询 1 中的查询更改为
$query = "SELECT * From
代码工作正常,下面是我的下一个和上一个按钮的代码。
Previous Button
if ($page > 1){
echo "<a href='$targetpage?page=$prev&type=$type&manufacturer=$manufacturer&year=$year'><div class='previous'><img src='images/PrevButton1.fw.png' width='108' height='58' style='border: none;'/></span></a>";
}else{
echo "<span class='disabled'><div class='previous'>Previous</span></span>"; }
Next Button
if ($page < $lastpage){
echo "<a href='$targetpage?page=$next&type=$type&manufacturer=$manufacturer&year=$year'><div class='next'><img src='images/MoreButton1.fw.png' width='108' height='58' style='border: none;'/></span></a>";
}else{
echo "<span class='disabled'><div class='next'>More</span></span>";
}
无论如何我可以在计数查询中包含不同的值吗?因为我认为它向第二个查询返回不同的值。