Php 无法发送级别以切换页面

Php 无法发送级别以切换页面,php,pagination,Php,Pagination,我正在进行数组分页。我在建立方程式时遇到了一些困难。我想要的是什么时候 $CurrentPage = 1 then $Start = 1, if $CurrentPage = 2 then $Start = 30, if $CurrentPage = 3 then $Start = 60, if $CurrentPage = 4 then$Start = 90 等等 如何写入if-else块?如果当前页面是一个,则从结果一显示(出于任何原因不是从结果0显示),如果页面大于结果(第1页)

我正在进行数组分页。我在建立方程式时遇到了一些困难。我想要的是什么时候

$CurrentPage = 1 then $Start = 1, 
if $CurrentPage = 2 then $Start = 30, 
if $CurrentPage = 3 then $Start = 60, 
if $CurrentPage = 4 then$Start = 90 
等等


如何写入if-else块?

如果当前页面是一个,则从结果一显示(出于任何原因不是从结果0显示),如果页面大于结果(第1页)的一个显示)*30

或者以更短的方式

$start = ($currentPage > 1) ? ((int)$currentPage - 1) * 30 : 1;
您还可以使用以下选项:

$Start = ($currentPage==1 ? 1 : ($currentPage-1)*30);
忘记所有的if/else。

保持简单:

$Start = max(1, ($currentPage-1) * 30);

那不应该是1吗→ 1, 2 → 31, 3 → 61等等?只有一个问题:如果
$currentPage
不是int或小于1,会发生什么?clentfort,这显然是此代码的先决条件。如果该值来自用户,我们希望它经过验证!
$Start = max(1, ($currentPage-1) * 30);