How to show count ids start from where it left from previous page?
How to show count ids start from where it left from previous page?
I am using server side solution.
I have more than 400 entries.
Lets assume I am vieweing 100 records per page.
Second page starts again counting 1 to 100 for the count. How can i make it start from 101.
I am not sending database ids since I want to start to count from 1 however I sort the list.
Therefore I am looping over a var $i starting from 1. But for everypage $i starts from 1. How can i bind it with page number?
Here is my api.php:
....
$i = 1;
foreach ($users as $user) {
$response["data"][] = [
"id" => $i,
'Name' => $user['Name'],
'Surname' => $user['Surname'],
'tc' => $user['tc'],
'gsm' => $user['gsm'],
"gorev" => $user['gorev'],
'girdi' => $user['girdi'],
'actions' => $user['id']
];
$i++;
}
echo json_encode($response);
This question has an accepted answers - jump to answer
Answers
Solved it.
There is start data sent to api.
Rather than assigning $i to 1, I did it like tihs:
$i = $_POST["start"] + 1;
It works like a charm..
Thanks for posting back - good to hear you have a solution. You might want to add a check for the
start
parameter being an integer. I don't think with the above it would cause any security issues if it wasn't, but it might be good practice just to check in case anyone tries any funny business!Allan