I have a report ( table ) containing user registrations using the Bootstrap framework.
Next to each record line is Edit. Clicking on this option would call the Modal
window, and open the information for that record specifically.
Theoretically, I would have to pass the PHP ID of each record to the Modal
window, and from there, via mysqli_fetch_array
, import the data from the database and display in Modal
.
But how to do that? Via Javascript?
Here is the code snippet for the report:
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Nome</th>
<th>Usuário</th>
<th>E-mail</th>
<th>Cidade</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
while ($linha = mysqli_fetch_assoc($resultado))
{
$id = $linha['id'];
$numero=$linha['nome'];
$protol=$linha['usuario'];
$protol=$linha['email'];
$cidade = $linha['cidade'];
$cidade1=utf8_encode($cidade);
echo '<tr>';
echo '<td>'.$linha['nome'].'</td>';
echo '<td>'.$linha['usuario'].'</td>';
echo '<td>'.$linha['email'].'</td>';
echo '<td>'.$cidade1.'</td>';
// Aqui iria o botão Editar
echo '<td><span class="glyphicon glyphicon-remove" aria-hidden="true" data-target="#" data-toggle="modal"></span></td>';
echo '</tr>';
}
?>
</tbody>
</table>
Here is the modal Bootstrap window:
<div class="modal fade bs-example-modal-lg" id="addBookDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Edição de Usuário</h4>
</div>
<div class="modal-body">
<!-- Aqui iria as informações do usuário a ser editado -->
</div>
</div>
</div>
</div>