开发者

Math - Adding with PHP

开发者 https://www.devze.com 2023-01-01 20:26 出处:网络
Basically I can\'t get it right. I need something like this: if($p == 1) { $start = 0; $limit = 16; } The numbers must add on depending on the value of the $p, e.g. if $p is 5 then the values of $

Basically I can't get it right.

I need something like this:

if($p == 1)
{
    $start = 0;
    $limit = 16;
}

The numbers must add on depending on the value of the $p, e.g. if $p is 5 then the values of $start and $limit would be:

if($p == 5)
{
    $start = 64;
    开发者_JAVA百科$limit = 80;
}

The math is to add 16, depending on the value of $p.


$start = ($p - 1) * 16;
$limit = $start + 16;

And don't forget to add a test for when $p < 1


$start = ($p - 1) * 16;
$limit = $p * 16;
0

精彩评论

暂无评论...
验证码 换一张
取 消