2
I’m creating pagination inside a div
and I intend that from page to page returns 5 in 5 lines, but it’s not working, when I click to open the second page does not return 5 different lines, only changes the first and last as shown in the image:
in this image returns the first 5 lines:
this image returns when I click to open page 2, where it only changes from the previous line and removes the first line from the previous page:
Code:
<?php
require("conexao.php");
require("init.php");
$itens_por_pagina1 = 5;
$pagina1 = intval($_GET['pagina1']);
$query1 = "SELECT * FROM raddb.Grupo ORDER BY Discricao ASC LIMIT $pagina1, $itens_por_pagina1";
$result1 = $conn->query($query1) or die($conn->error);
$produto1 = $result1->fetch_assoc();
$num1 = $result1->num_rows;
$num_total1 = $conn->query("SELECT * FROM raddb.Grupo ORDER BY Discricao ASC")->num_rows;
$num_paginas1 = ceil($num_total1/$itens_por_pagina1);
<div class="table-responsive" id="employee_table1">
<?php if($num1 > 0){ ?>
<table class="table table-hover table-striped lista-clientes1">
<legend><b>Grupos</b></legend>
<tr>
<span class="glyphicon glyphicon-filter" data-toggle="modal" data-original-title="Filter"></span><input type="text" class="input-search1" alt="lista-clientes1"/>
<th width="25%">Grupo</th>
<th width="30%">Ações</th>
</tr>
<?php do{ ?>
<tr>
<td><?php echo $produto1["Discricao"]; ?></td>
<td><button type="button" name="view1" id="<?php echo $produto1["Id"]; ?>" data-toggle="modal" href="#dataModal1" class="btn btn-warning btn-sm view_data1" /><span class="glyphicon glyphicon-edit"></span></button></td>
</tr>
<?php } while($produto1 = $result1->fetch_assoc()); ?>
</table>
<nav>
<ul class="pagination">
<li>
<a href="index.php/novoutilizador?pagina1=0" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<?php
for($i=0;$i<$num_paginas1;$i++){
$estilo = "";
if($pagina1 == $i)
$estilo = "class=\"active\"";
?>
<li <?php echo $estilo; ?> ><a href="index.php/novoutilizador?pagina1=<?php echo $i; ?>"><?php echo $i+1; ?></a></li>
<?php } ?>
<li>
<a href="index.php/novoutilizador?pagina1=<?php echo $num_paginas1-1; ?>" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
<?php } ?>
</div>
</div>