Level 75
You need to understand basic pagination
$offset = ($page - 1) * $perpage;
So page 2
$offset = (2 - 1) * 10;
equals 10 (skip first 10 you are on page 2)
- Page 1 = 0
- Page 2 = 10
- Page 3 = 20
- etc
I want to understand this code ?!
how can I change this link (url) to fit pagination of any page ?
$limit = 10;
$url = 'https://firestore.googleapis.com/v1beta1/projects/zadcall/databases/(default)/documents/users? key=AIzaSyD8LI57uBNjHG_r8QWpSvt8DXsdd5S5eKw&pageSize='.$limit.'&pageToken='.$nextPageToken;
$json = json_decode(file_get_contents($url), true);
$calls = $json['documents'];
if(isset($json['nextPageToken'])){
$nextPageToken = $json['nextPageToken'];
}else{
$nextPageToken = null;
}
Please or to participate in this conversation.