我想知道是否有人可以幫我解決一些分頁問題。使用pajinate,我最初把它放在一起,但它似乎被竊聽。我想添加「上一頁」和「回頁首」以及「下一頁」和「最後一頁」按鈕。我試着先執行'回到開始'和'上一個'按鈕,但他們不能正常工作。如果有人能夠幫助我一點,那就太棒了。在附註中,我設置了一次顯示10個數字的範圍,但每次點擊更高的頁碼時,它都會附加4-5個數字,對此問題的任何見解都將不勝感激。eBay購物API分頁
<?php
// find out total pages
$totalpages = $resp->paginationOutput->totalPages;
echo "Total Results: ";
echo $totalpages.' pages ';
// get the current page or set a default
if (isset($_GET['pgno']) && is_numeric($_GET['pgno'])) {
// cast var as int
$currentpage = (int) $_GET['pgno'];
} else {
// default page num
$currentpage = 1;
} // end if
// if current page is greater than total pages...
if ($currentpage > $totalpages) {
// set current page to last page
$currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < 1) {
// set current page to first page
$currentpage = 1;
} // end if
// the offset of the list, based on current page
$offset = ($currentpage - 1) * $entriesPerPage;
/****** build the pagination links ******/
// if not on page 1, don't show back links
if ($currentpage > 1) {
// show << link to go back to page 1
if(null!=$queryString){
// echo " <a href='{$_SERVER['PHP_SELF']}?$queryString¤tpage=1'><<</a> ";
}else{
// echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> ";
}
// get previous page num
// $prevpage = $currentpage - 1;
// show < link to go back 1 page
// echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> ";
} // end if
// range of num links to show
$range = 10;
// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
// if it's a valid page number...
if (($x > 0) && ($x <= $totalpages)) {
// if we're on current page...
if ($x == $currentpage) {
// 'highlight' it but don't make a link
echo " [<strong>$x</strong>] ";
// if not current page...
} else {
// make it a link
echo " <a href='".add_url_param('pgno',$x)."'>$x</a> ";
} // end else
} // end if
} // end for
?>
更明確:我將<更改爲< – JohnnyFaldo
這對我有用。重新調整總頁數。有更多的頁面,但我只想要一次顯示10個數字,當你選擇另一個頁面通知時,它會附加更多。我的下一個問題是獲取下一個和最後一個按鈕。 http://valueguide.pga.com/file-exec/f/ebaystore/h/true – MDez
唯一的問題,當我選擇它恢復到一般的結果,而不是對當前過濾的結果your're另一頁。 – MDez