Problems with pagination in php

0

I just discovered the flaw. The url was the answer!

My code was sending the address as follows: localhost / portabilities / surveys.php? page = 2 & selector = requested

What really showed the numbering buttons was this: localhost / portabilities / surveys.php? page = 2 & type = situation & selector = requested & filter =

So I just needed to modify the last line that refers to the numbering for the equivalent as follows:

localhost / portabilities / surveys.php? page = 1 & type = $ situation & selector = $ selector & filter = $ filter

In the php script:

//PAGINAÇAO
//Verificar a pagina anterior e posterior
$pagina_anterior = $pagina - 1;
$pagina_posterior = $pagina + 1;
print "<div class='container'>
<div>
                <ul class='pagination'>
                    <li>";
if($pagina_anterior != 0){
    print "<a href='pesquisas.php?pagina=$pagina_anterior&tipo=$tipo&seletor=$seletor&filtro=$filtro' aria-label='Previous'>
                                <span aria-hidden='true'>&laquo;</span>
                            </a>";
}
else{
    print "<span aria-hidden='true'>&laquo;</span>";
}
print "</li>";
//Apresentar a paginacao
for($i = 1; $i < $num_pagina + 1; $i++){
    print"<li><a href='pesquisas.php?pagina=$i&tipo=$tipo&seletor=$seletor&filtro=$filtro'>$i</a></li>";
}
print "<li>";
if($pagina_posterior <= $num_pagina){
    print " <a href='pesquisas.php?pagina=$pagina_posterior&tipo=$tipo&seletor=$seletor&filtro=$filtro' aria-label='Previous'>
            <span aria-hidden='true''>&raquo;</span>
        </a>";
}else{
    print "<span aria-hidden='true'>&raquo;</span>";
}
print "</div></div>";
//FIM PAGINAÇAO

The tip is for those who have the same difficulty as I had.

    
asked by anonymous 08.05.2018 / 21:21

0 answers