Answer the question
In order to leave comments, you need to log in
How to make pagination when receiving a photo via VK Api?
There is a site where we get photos from the VK album, how to make pagination?
<div class="row photos">
<?php
$fpt = file_get_contents('https://api.vk.com/method/photos.get?owner_id=-183487496&album_id=265483073&count=200&rev=1&access_token=a74314ae&v=5.50');
$jjs = json_decode($fpt);
$jrnd = $jjs->response->count;
$x=-1;
while ($x<16)
{
$x++;
$pid = $jjs->response->items[$x]->photo_604;
echo '<div class="col-sm-6 col-md-4 col-lg-3 item"><a data-lightbox="photos" href="';
echo $pid;
echo '"><img class="img-fluid" src="';
echo $pid;
echo '"></a></div>';
}
?>
</div>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
<div class="row photos">
<?php
$apage = $_GET['page'];
if(isset($apage)){
$aoffset = $apage-1;
$aoffset = 16*$aoffset;
}
$fpt = file_get_contents('https://api.vk.com/method/photos.get?owner_id=-183487496&album_id=265483073&count=200&offset='.$aoffset.'&rev=1&access_token=a74&v=5.50');
$jjs = json_decode($fpt);
$jrnd = $jjs->response->count;
$apage = ceil($jrnd/16);
$x=-1;
while ($x<15)
{
$x++;
$pid = $jjs->response->items[$x]->photo_604;
echo '<div class="col-sm-6 col-md-4 col-lg-3 item"><a data-lightbox="photos" href="';
echo $pid;
echo '"><img class="img-fluid" src="';
echo $pid;
echo '"></a></div>';
}
?>
<ul class="pagination">
<?php
$z=0;
while ($z < $apage){
$z++;
echo '<li class="page-item"><a class="page-link"';
$bpage = 1;
if(isset($_GET['page'])){
$bpage = $_GET['page'];
}
if ($z != $bpage){
echo 'href="index.php?page=';
echo $z;
echo '"';
}
echo '>';
echo $z;
echo '</a></li>';
}
?>
</ul>
</div>
</div>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question