$page = ((isset($_GET['pagina']) && intval($_GET['pagina']) > 1)? intval($_GET['pagina']) : 1) - 1;
$limite = 12;
$atual = $page * $limite;
$limit = " LIMIT {$atual}, {$limite}";
// Registros limitados
$query = $pdo->query("SELECT * FROM imovel ".trim($where, ' AND ').$limit);
$total = $pdo->query("SELECT * FROM imovel ".trim($where, ' AND '));
$total2 = $total->rowCount();
$qtdpage = ceil($total2/$limite); // Quantidade de páginas
for ($i = 1; $i < $qtdpage; $i++){
echo '<li><a href="busca?pagina='.$i.'">'.$i.'</a></li>';
}
With this code I am retrieving the records of my query and retrieving the total records of this query.
The filter variables are being sent via POST
and when I change the type page from 1 to 2 , the filter is lost, ie it understands that no parameters have been passed and then apply the default search.
How do I, when I click on the page 2
, 3
, 4
keep the parameters of the current search?
This is what happens when I move to page 2 or some other one.