I have a page with a table whose code field is link that opens a modal. I need that when opening the modal, show another table, only with the data according to the value of the field (code) clicked. How do I get the value of the chosen field within the modal
Does anyone know how to do it?
Code:
<table class="table table-bordered table-hover center-text" name="carrtab" id="carrtab"
style="background-color: #ffffff;">
<thead align="center">
<tr class="danger">
<th class="text-center">Data</th>
<th class="text-center">Tipo</th>
<th class="text-center">Descrição</th>
<th class="text-center">Cliente</th>
<th class="text-center">Usuario</th>
<th class="text-center">Link</th>
</tr>
</thead>
<tbody>
<?
$tipoentradalog = post('tipoentradalog');
$usuario = post('usuario');
$codcliente = post('codcliente');
$datade = post('datade');
$dataate = post('dataate');
$codigo = post('codigo');
$sql = "select
l.datacriacao,
tl.nome as tipo,
l.descricao,
cli.nome as cliente,
us.nome as usuario,
l.codigo
from log l
inner join cliente cli on cli.codcliente=l.codcliente
inner join usuario us on us.codusuario=l.codusuario
inner join empresa emp on emp.codempresa=l.codempresa
inner join tipoentradalog tl on tl.codtipoentradalog=l.codtipoentradalog
where cli.codempresa=$codempresa
and l.datacriacao between '$datade%' and '$dataate%' ";
if($usuario != ""){
$sql .= " and us.codusuario=$usuario ";
}
if($codcliente != "") {
$sql .= " and cli.codcliente=$codcliente ";
}
if($tipoentradalog != "") {
$sql .= " and tl.codtipoentradalog=$tipoentradalog ";
}
$rst = my_query($connR, $sql);
foreach($rst as &$row){
?>
<tr>
<td align="center"><?=normalDate($row['datacriacao']);?></td>
<td align="center"><?=$row['tipo']?></td>
<td align="center"><?=$row['descricao']?></td>
<td align="center"><?=$row['cliente']?></td>
<td align="center"><?=$row['usuario']?></td>
<td align="center"><a class="link-target" role="link" data-toggle="modal" href="#modalContainer" aria-expanded="false" aria-controls="modalContainer" style="text-decoration: none; color: black;"><?=$row['codigo']?></a></td>
</tr>
<?
if($row['codigo'] != "")
{
global $codigo;
$codigo = $row['codigo'];
}
}?>
</tbody>
</table>
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="myModalLabel">Extrato Rodízio</h3>
</div>
<div class="modal-body">
<h4>Chat</h4>
<table name="tabrod" id="tabrod" class="table table-bordered table-hover center-text" style="background-color: #ffffff;">
<thead align="center">
<tr class="danger">
<th class="text-center">Data</th>
<th class="text-center">Cliente</th>
<th class="text-center">Usuario</th>
</tr>
</thead>
<tbody>
<?
$sql = "select cli.codcliente, cli.nome, emp.nome as empresa from cliente cli
inner join empresa emp on emp.codempresa=cli.codempresa
where cli.codcliente=$codigo;";
$rst = my_query($connR, $sql);
foreach ($rst as $row) {
?>
<tr>
<td align="center"><?= $row['codcliente']; ?></td>
<td align="center"><?= $row['nome'] ?></td>
<td align="center"><?= $row['empresa'] ?></td>
</tr>
<?
}?>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
</div>
</div>
</div>