第一頁應該是1,但它的-1和下一頁應該是2,但它的0分頁下頁應該是2,但爲0
我怎樣才能使這項工作?我試圖編輯$頁面,但是當我這樣做時,if/else會變得更加奇怪。
我加入了整個代碼...
...
$resultt= "SELECT * FROM users WHERE AND country='$okc' AND state='$oks'";
if(!empty($a1) && empty($a2)){
$resultt .= " AND aar>=";
...
}
有超過1 if語句。
$result = mysqli_query($con,"$resultt");
$rec_limit = 19;
$row = mysqli_fetch_array($result);
$rec_count = $row[0];
if(isset($_GET['page']))
{
$page = $_GET['page'] + 1;
$offset = $rec_limit * $page ;
}
else
{
$page = 0;
$offset = 0;
}
$left_rec = $rec_count - ($page * $rec_limit);
$resultt .= "LIMIT $offset, $rec_limit";
$sql = $resultt;
$retval = mysqli_query($con, "$resultt");
if($page > 0)
{
$last = $page - 1;
echo "<a href=\"$_PHP_SELF?page=$last\">Last 10 Records</a> |";
echo "<a href=\"$_PHP_SELF?page=$page\">Next 10 Records</a>";
}
else if($page == 0)
{
echo "<a href=\"$_PHP_SELF?page=$page\">Next 10 Records</a>";
}
else if($left_rec < $rec_limit)
{
$last = $page - 2;
echo "<a href=\"$_PHP_SELF?page=$last\">Last 10 Records</a>";
}
while($row = mysqli_fetch_array($retval, MYSQL_ASSOC))
{
}
如果這是'php'你可能想改變'$ _GET {「頁面」}''到$ _GET [「頁」]' – Trix