-1
Hello, good morning, I’m looking for help because I’m having trouble creating a results pagination, I made a page that contains two search fields, "what you search" and "where you search", it works and makes the correct filter, however I am not able to make the pagination to limit the researched results, where I am missing in the following code?
$conexao =mysqli_connect($host,$user,$pass,$bank);
$pagina = (isset($_GET['pagina'])) ? $_GET['pagina'] : 1 ;
$consulta1 ="SELECT * FROM registro_clientes";
$qrTotal =mysqli_query($conexao,$consulta1) or die(mysqli_error());
$numTotal =mysqli_num_rows($qrTotal);
$quantidade = 2;
$totalPagina=ceil($numTotal/$quantidade);
$inicio = ($quantidade * $pagina) - $quantidade;
if(mysqli_connect_errno($conexao)){
echo "erro conect hen";
}else{
if(isset($_GET['buscar'])&& isset($_GET['onde'])){
$nome = $_GET['buscar'];
$bairro = $_GET['onde'];
$consulta = "SELECT * FROM registro_clientes
WHERE nome_cliente LIKE '%$nome%' AND bairro LIKE '%$bairro%'
ORDER BY preferencial ASC
LIMIT $inicio, $quantidade ";
$executar = mysqli_query($conexao,$consulta);
$total = mysqli_num_rows($executar);
echo "Encontrado ".$total. " resultado(s):";
echo "<br>";
echo "<hr>";
while ($ln=mysqli_fetch_array($executar))
Thank you Daniel for answering me, I did following tutorials, maybe I’m not saying correctly what I mean. So I did what you told me, okay, it worked, okay,
– Henrique Oliveira
except that now I came across another question that is not in the lines of code, which is the pagination, can you point me where I am missing in this question, below the code: echo '<a href="? page=1"> first page </a> - '; for($i = 1; $i <= $totalPagina; $i++){ if($i == $page) echo $i; Else echo"<a href='results.php? page=$i'>". $i. "</a>"; } echo" - <a href="? pagina=$totalPagina"> ultima pag </a> ";
– Henrique Oliveira