0
I have a report (table) containing user registrations using the Bootstrap framework.
Next to each row of record there is the Edit option. By clicking on this option the action would be to call the window Modal
, and open up the information on that record specifically.
Theoretically, I would have to pass the ID (string PHP) from each record to the window Modal
, and from there, I saw mysqli_fetch_array
, import the data from the database and display it in the Modal
.
But how to do this? Via Javascript?
Follow the code snippet from 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 the Bootstrap modal 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>
Speaks Henry! So I don’t particularly like refresh methods on the page either. This idea of yours has cleared things up a bit. If you give me an example, it will certainly help a lot. By the way, this idea of using GET to capture the ID and pass this parameter to the URL is the key to solving this whole issue.
– Alan Garmatter
What is your level of js? knows something?
– Henrique Van Klaveren
Just to finish the post. I was able to solve the question as follows: echo '<a href="#"><div class="well-Sm" data-toggle="modal" data-target="#visualizaranexo" data-doc="'. $varquivo. '" style="margin-bottom:5px;"><span class="glyphicon glyphicon-Paperclip" Aria-Hidden="true"></span>'. $varquivo. '</div></a>';
– Alan Garmatter