Php 易趣购物API分页

Php 易趣购物API分页,php,pagination,ebay-api,Php,Pagination,Ebay Api,我想知道是否有人能帮我解决我店里的分页问题。使用pajinate,我最初把它放在一起,但它似乎被窃听了。我想添加“上一页”和“回到开头”以及“下一页”和“最后一页”按钮。我尝试先实现“返回开始”和“上一步”按钮,但它们不能正常工作。如果有人能帮我一点忙,那就太好了。顺便说一句,我有一套一次显示10个数字,但每次我点击一个更高的页码,它会附加4-5个数字,任何关于这个问题的见解都将不胜感激 <?php // find out total pages $totalpages = $resp-

我想知道是否有人能帮我解决我店里的分页问题。使用pajinate,我最初把它放在一起,但它似乎被窃听了。我想添加“上一页”和“回到开头”以及“下一页”和“最后一页”按钮。我尝试先实现“返回开始”和“上一步”按钮,但它们不能正常工作。如果有人能帮我一点忙,那就太好了。顺便说一句,我有一套一次显示10个数字,但每次我点击一个更高的页码,它会附加4-5个数字,任何关于这个问题的见解都将不胜感激

<?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&currentpage=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
?>

您已将上一页注释掉,并使用$_GET['currentpage']而不是$_GET['pgno'],这对我很有用:

<?
$totalpages = 10;
if (isset($_GET['pgno']) && is_numeric($_GET['pgno'])) {
// cast var as int
$currentpage = (int) $_GET['pgno'];
} else {
// default page num
$currentpage = 1;
} // end if

echo $currentpage;
echo "/".$totalpages;
echo "<br />";

// 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&pgno=1'><<</a> ";
}else{
  echo " <a href='{$_SERVER['PHP_SELF']}?pgno=1'><<</a> ";
}
// get previous page num
$prevpage = $currentpage - 1;
// show < link to go back 1 page
 echo " <a href='{$_SERVER['PHP_SELF']}?pgno=$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='".$_SERVER['PHP_SELF']."?pgno=$x"."'>$x</a> ";

     } // end else
   } // end if
 } // end for
 ?>

更清楚地说:我改变了这一点,这对我来说是可行的。重新调整总页数。有更多的页面,但我只希望一次显示10个数字,当您选择另一个页面时,请注意它附加了更多。我的下一个问题是在那里设置下一个也是最后一个按钮。唯一的问题是,当我选择另一个页面时,它会恢复为常规结果,而不是当前的筛选结果。这不是答案,它甚至看起来都不像是一个好的评论。问题和答案并不是用来讨论事情的媒介。你要么知道答案,要么不知道。如果有什么你想问的用户,考虑发布一个直接评论的问题。另外,请查看StackOverflow帮助部分。
$offset = ($currentpage - 1) * $entriesPerPage;


if ($currentpage > 1) {

?where comes this variable