1
My problem is this: I have this code that displays several cars on a table:
<?php
$veiculos = "SELECT * from veiculo ";
$veiculos .= "WHERE id_secretaria = '1' ORDER BY placa DESC LIMIT 2"; //mudar conforme o id da secretaria
$query_veiculos = mysqli_query($conexao,$veiculos);
if(!$query_veiculos) {
die("Falha na consulta ao banco");
}
while ( $exibir = mysqli_fetch_array($query_veiculos)) {
$placa = $exibir["placa"];
?>
<li><a href="#" data-toggle="modal" data-target="#mostrar-veiculo" data-id='$placa' id="btnEditar"><?php echo "Modelo: ".$exibir["modelo"]." | Placa: ".$placa." ";?><i class="ti-car pull-right"></i></a></li>
<?php } ?>
Clicking on the link opens a modal with the following code:
<?php
include('../conecta-db.php');
$placa = $_POST["placa"];
$veiculos = "SELECT * from veiculo ";
$veiculos .= "WHERE placa = '{$placa}'";
$query_veiculos = mysqli_query($conexao,$veiculos);
if(!$query_veiculos) {
die("Falha na consulta ao banco");
}
?>
<!-- Modal -->
<div class="modal fade" id="mostrar-veiculo" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Veiculo selecionado</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<!--Lista com os cadastros-->
<div class="row">
<div class="col-md-12">
<div class="container">
<table class="table table-responsive">
<thead class="bg-primary">
<tr style="color: #fff;">
<th scope="col">#</th>
<th scope="col">Placa</th>
<th scope="col">Modelo</th>
<th scope="col">Ano</th>
<th scope="col">Km Rodados</th>
</tr>
</thead>
<tbody>
<?php $i = 1;?>
<?php
while ( $exibir = mysqli_fetch_array($query_veiculos)) {
?>
<tr>
<th scope="row"><?php echo $i; ?></th>
<td><?php echo $exibir["placa"]; ?></td>
<td><?php echo $exibir["modelo"]; ?></td>
<td><?php echo $exibir["ano"]; ?></td>
<td><?php echo $exibir["km_rodados"]; ?></td>
</tr>
<?php $i++;} ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="botao-fechar" style="width: 90%;
display: table;
margin-left: auto;
margin-right: auto;
position: static;">Fechar</button>
</div>
</div>
I want to know how I can recover the value of the card variable in the modal to call only the line that has the same card in the database. follow system images:
Here the modal where you should display all car information:
Is an ajax?.....
– Sam
And this table
Carros desta secretária (ou seria secretaria?)
what’s her deal? It just came up in the middle of the question– user60252