I'm having this problem where my PHP code is concatenating instead of adding
$offset=$_POST['offset']; //Get the offset
$searchLimit = 10;
$searchCount = count(sql) //For the purpose of this question, it returns the result count
Now I want to calculate the 'from' display for pagination, so I do
$from = ($offset*$searchLimit)+1;
It works fine when
$offset == 0
I get the expected result which is 1. But when
$offset == 1
It gives me 101. Basically it is concatenating the 10 and 1 to give me 101. I've tried the following
$from = (int)($offset*$searchLimit)+1
$from = ((int)($offset)*$searchLimit)+1
$from = (((int)($offset)*$searchLimit)+1)
I even tried
$offset = (int)$_POST['offset'];
But all of them are giving the same result.
intvalfunction? php.net/manual/en/function.intval.php$from = (intval($offset*$searchLimit)+1)but that doesn't help either ..$offset = intval($_POST['offset']);instead$from = ($offset*$searchLimit)+1;'working fine' if it returns0as stated? (0*10)+1 == 1 surely?$offset = (int)$_POST['offset']but that didn't do anything different ..