0
I made a pagination using PHP that is working perfectly, however, when arriving at the penultimate page(10), the last page(11) it comes as a result "loose" and does not come stylized as if it were a "bug" Follows the image with the error:
Follows the code:
<ul class="pagination">
<?php
$pagina_atual = (!isset($_GET['p']))? 1 : $_GET['p'];
$max_results = 1;
$prev = ($pagina_atual - 1);
$next = ($pagina_atual + 1);
$total_pages = ceil($paginas / $max_results);
$pagination = '';
if($paginas > 1) {
$pagination .= '<li class="pagination_reborn"><a class="page " href="logacesso?p='.$prev.'">«</a></li> ';
}
for($i = max(1, $pagina_atual - 4); $i <= min($pagina_atual + 4, $total_pages); $i++) {
if(($paginas) == $i)
{
$pagination .= $i;
}
else
{
if($pagina_atual == $i) {
$pagination .='<li id="active_page" class="pagination_reborn"><a class="page" href="logacesso?p='.$i.'">'.$i.'</a></li>';
} else {
$pagination .= '<li class="pagination_reborn"><a class="page" href="logacesso?p='.$i.'">'.$i.'</a></li>';
}
}
}
if($pagina_atual < $total_pages)
{
$pagination .= '<li class="pagination_reborn"><a href="logacesso?p='.$next.'">»</a></li>';
}
if($next == $i) {
$pagination .= '<li class="pagination_reborn"><a class="page" href="logacesso?p='.$i.'">'.$i.'</a></li>';
}
echo $pagination;
?>
Try enumerating For from scratch, since 0 is an index.
– Wanderson Rodrigo