如果您知道您所在的页面以及每页的条目数,您可以计算它:
$limit = 7;
$page = 2;
$total = 21;
$upper = min( $total, $page * $limit);
$lower = ($page - 1) * $limit + 1;
printf( "Displaying %d - %d of %d on Page %d\n", $lower, $upper, $total, $page);
现在,只需遍历第 1 - 3 页即可查看输出Codepad:
Displaying 1 - 7 of 21 on Page 1
Displaying 8 - 14 of 21 on Page 2
Displaying 15 - 21 of 21 on Page 3
编辑:使用 OP 的变量:
$upper = min( $products_total, $pager_current * $limit);
$lower = ($pager_current - 1) * $limit + 1;
printf( "Displaying %d - %d of %d on Page %d\n", $lower, $upper, $products_total, $pager_current);