Modal inside code with table and while loop

0

I have a code where I put the table data on a page within a structure with while and so far so good, my problem is that inside this structure there are buttons that call modal windows, my question is how to add modal code within this while structure in the right way?

Follow my code:

<div style='white-space:nowrap;'>
<table class='table table-striped'>
<thead>
<tr><th>Situação</th><th>Contrato</th><th>Número</th><th>Conclusão Prevista</th><th >Alterar</th><th>Detalhes</th></tr>
</thead>

<?php while ($exibirRegistros = mysqli_fetch_array($consultafull)) {
$codigo = $exibirRegistros[0];
?>

<tbody>
<tr><td style='background-color:#F8F8FF'>$situacao</td><td style='background-color:#F0F8FF'>$contrato</td><td style='background-color:#F8F8FF'>$numero</td><td style='background-color:#F0F8FF'>$data às $hora</td><td align='center' style='background-color:#F8F8FF;'><button style='background:transparent;border:none; color: #CD3333;' class='glyphicon glyphicon-edit' data-toggle='modal' data-target='#Alt$codigo'></button></td><td   style='background-color:#F8F8FF' align='center'><button style='background:transparent;border:none; color:#3A5FCD;' class='glyphicon glyphicon-search' data-toggle='modal' data-target='#Modal$codigo'></button></td></tr>
</tbody>          
<?php
}
?>
<!-- Esse final que fecha a tabela é prejudicado 
quando coloco o modal -->
</table></div>
<!-- O modal antes desse fechamento (e dentro da estrutura while) dá erro e deixa a 
pagina totalmente bagunçada -->

The modal code I want to put is:

<!-- Modal  -->
<div class="modal fade" id="Alt<?php echo $codigo; ?>" role="dialog" data-backdrop="false" style=" background: rgba(0,0,0,0.5);">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<div class='row'>
<div class='col-sm-5'>
<h4 class="modal-title">Alterar</h4> 
</div>
<form method="post" action="func/define.php" enctype="multipart/form-data">
<div class='col-sm-5 text-right' style='float: right'>
<td align='center'><button type='submit' class='btn btn-danger'>Alterar</button>   <form align='center'><button type='button' class='btn btn-primary' data-dismiss='modal'>Sair</button>
</div>
</div>
</div>
<div class="modal-body">
<p>	
<?php echo $codigo; ?>
</p>
</div>
</div>
</div>
</div>
<!--Fim Modal -->

Note: This modal has to be integrated within the while structure by the code that it takes from each table to show the data of the respective position.

    
asked by anonymous 18.06.2018 / 02:28

0 answers