0
$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 recovering the total records of that query.
Filter variables are being sent via POST
and when I change page type of the 1 to the 2, the filter is lost, meaning it understands that no parameters have been passed and then applies the default search.
Like, by clicking on the page 2
, 3
, 4
keep the current search parameters?
This is what happens when I move to page 2 or any other.
My pagination doesn’t make a query, it just tries to switch to the page
2
since I already loaded everything I needed on the first consultation.– Marcos Vinicius
I don’t understand your problem so...
– Jorge B.