Php 修改分页脚本以在第一页上显示与其他页面不同的行数

Php 修改分页脚本以在第一页上显示与其他页面不同的行数,php,pagination,Php,Pagination,我有一个简单的分页脚本: $product_nr = count($query); // counts the number of products $totalpages = ceil($product_nr / $rowsperpage); if ($currentpage > $totalpages){ $currentpage = $totalpages; } $offset = (($currentpage - 1) * $rowsperpage); 代码设置为每页显示2

我有一个简单的分页脚本:

$product_nr = count($query); // counts the number of products
$totalpages = ceil($product_nr / $rowsperpage);  
if ($currentpage > $totalpages){ $currentpage = $totalpages; } 
$offset = (($currentpage - 1) * $rowsperpage);
代码设置为每页显示20行->$rowsperpage=20

我需要了解如何在第一页上仅显示18行,并将剩余的2行添加到$product_nr中,这样就不会中断其他页面每页20行的分页

基本上:

1st page - 18 rows;
the other pages would show 20 rows per page from the remaining rows.

有什么想法吗?

如果可能,您可以设置$在第一页上单独显示行,即如果$currentpage==1,则$rowperpage=18
if($currentpage == 1)
$rowsperpage = 18;
else
$rowsperpage = 20;
对于所有其他页面,您必须设置偏移量-2 i、 e

如果($currentpage!=1){$offset=(($currentpage-1)* $rowsperpage))-2;}