0
I have a menu with the option to view the registered phones, only the numbers that were registered without showing the rest of the data, the intention and the user clicks on the option to view in the menu and opens a modal in this modal appears the registered numbers, more or less 8 per page... The problem is that I can open the modal and appears only the first number of the database in this modal and does not appear the pagination below also...
Follow the code of the index.php page:
<?php
include_once("../conn/conexao.php");//faz a conexao com o banco de dados
//verifica a página atual caso seja informada na URL, senão atribui como 1ª página
$pagina = (isset($_GET['pagina']))? $_GET['pagina'] : 1;
//seleciona todos os itens da tabela
$cmd = "select * from tb_numeros";
$produtos = mysqli_query($conexao, $cmd);
//conta o total de itens
$total = mysqli_num_rows($produtos);
//seta a quantidade de itens por página, neste caso, 2 itens
$registros = 8;
//calcula o número de páginas arredondando o resultado para cima
$numPaginas = ceil($total/$registros);
//variavel para calcular o início da visualização com base na página atual
$inicio = ($registros*$pagina)-$registros;
//seleciona os itens por página
$cmd = "select * from tb_numeros limit $inicio,$registros";
$produtos = mysqli_query($conexao, $cmd);
$total = mysqli_num_rows($produtos);
//exibe os produtos selecionados
while ($produto = mysqli_fetch_array($produtos)) {
echo "<div class='modal fade' id='VisualizarT' tabindex='-1' role='dialog' aria-labelledby='modalLabel' aria-hidden='true'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>
<h3 class='modal-title' id='lineModalLabel' align='center'>Telefones Cadastrados</h3>
<div class='modal-body'>
<div class='form-group'>
<input type='text' name='numero' class='form-control' id='exampleInputPassword1' value=".$produto['numero']." style='text-align: center;' readonly='readonly' >
</div>
</div>
</div>
</div>
</div>
</div>
";
}
//exibe a paginação
for($i = 1; $i < $numPaginas + 1; $i++) {
echo "<a href='index.php?pagina=$i'>".$i."</a> ";
}
?>
that’s right, only that type, I click on the pagination and it has the 1,2,3 button... when I click on 2 or 3 in case I register more than 8 it leaves the modal... you know the error?
– Ferb
he closes the modal, but then I click on the modal again he ta in the second pagination
– Ferb
One of the things that will happen is that in the pagination links you reload the page (
index.php?pagina=$i
), therefore the modal will close anyway. Now, if you are closing without redirecting may be some problem related to your jQuery.– user98628
how do I do this in modal without having to redirect to another page
– Ferb
You can continue redirecting, but when the page reload with the new index, you would have to open the modal automatically. Or else you can use AJAX, but you will have to change almost everything in your code to suit this solution.
– user98628