0
I’m breaking my head on a problem. I hope you help me please. I’m listing all the records in the database. I need to get the line id as the click goes. I’m only getting the first line ID, when I click on the next line the variable gives me the first record again.
*I took all the unnecessary css and Php out of the code to be quick and easy to understand :)
index
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Nº do Cliente</th>
<th scope="col">Nome</th>
</tr>
</thead>
<tbody>
<?php
$Mostrar = new Crud();
foreach ($Mostrar->Listar() as $rs) {
?>
<tr>
<td><?php echo $rs['cli_id']; ?></td> <!--PRECISO DESSA VARIAVEL -->
<td><?php echo $rs['cli_nome']; ?></td>
</tr>
<?php include 'includes/clientes/cadastrarMoto.php'; ?> <!--AQUI FICA O MODAL PRA APRESENTAR O ID -->
<tr>
<td colspan="6">
<div class="pull-left">
<span class="material-icons adicionar" title="Motos" data-balao="tooltip" data-toggle="modal" data-target="#cadastrarMoto">storage</span></div> <!--CLICANDO AQUI VAI PARA UM MODAL -->
</td>
</tr>
<?php
}
?>
</tbody>
</table>
register.php
<div class="modal fade">
.........
<?php echo $rs['cli_id']; ?>
How so line?
– Lucas de Carvalho
I voted for the closing of your question as unclear. I did not understand what you are wanting. Bottom line: what would be "line id"?
– Wallace Maxters
I advise you to rephrase the question because it is very confusing and if possible put the class 'Crud' so that we can test and find the best solution for your case, Casso n want to put the 'Crud' class although q explain the question better and explain what this Class would do
– romulo henrique
See if this link helps - http://www.davidchc.com.br/video-aula/videoaula-criando-carrinho-de-compra-com-php-orientado-a-objetos-parte-1/
– José Gomes
Thank you for answering personally. I’m sorry if I was unclear. https://ibb.co/dpcGUo (SYSTEM IMAGE.) https://jsfiddle.net/njfLwx83/2/ (JA COM O METODO LISTAR() ) . I hope it’s a little clearer. thank you staff!
– Joao Torres
https://ibb.co/h5TRvT this is the modal screen. with <?php echo $rs['cli_id']; ? >. but it is fixed in COD 42. when I click on the SPAN of the COD 41 line, echo shows COD 42.
– Joao Torres
I tried to take the GET as parameter. even so it only shows the first cli_id in the foreach loop. =\
– Joao Torres