0
I have the following question, I have one while
in PHP, and in this while
have a form and a button of Submit who sends this form, but as there are several records he repeats this form and the system detects only the first form on the list, the others he does not do the Submit, for example, I have 20 records, 20 are generated Forms, no matter how much I change the form nº 18, it will save the 01.
To be clear, each registration brings me a status of the product in a select
, and I want to leave this choice option to the user, and when he chooses a status in that select
(who is in the form), the system do the update at the bank.
this is the code while repeats how many results it finds:
<?php
while ($dados = $produtos->fetch_array()) {
?>
<tbody> <tr>
<td align="center"><?php echo $dados['id_oc']; ?></td>
<td align="center"><?php echo date('d/m/Y', strtotime($dados['data'])); ?></td>
<td align="center"><?php echo (number_format($dados['total'],0,",",".")); ?></td>
<td align="center"><?php if(!empty($dados['faccao'])) echo $dados['faccao']; else echo "-"; ?></td>
<td align="center">
<form action="" method="post" name="teste">
<select name="status" id="status_">
<option value="<?php echo $dados['status']; ?>"><?php echo $dados['status']; ?></option>
<?php
foreach ($arrEdital as $value => $name) {
echo "<option value='{$name}'>{$name}</option>";
}
?>
</select>
<td align="center"><input type="submit" name="status2" id="ok" value="ok" /> </td>
</form>
</td>
</tr></tbody>
<?php
}
?>
the problem is that it repeats this 20 times (for example), but when I change the select of the number 18 (for example), it takes the values of the first form (number 1 in this example)
20 Forms? You want to change 18 and it affects 18 instead of 1? Is that it? What have you done so far? I don’t understand pq 20, if I understood you have something equivalent to a grid, maybe Javascript and ajax could solve. Really can’t understand your question, try to be clearer please.
– Guilherme Nascimento
I changed the question, sorry if it wasn’t clear.
– Denis L. Murara
You can show where you’re putting the
while
? And also how are you getting this value on the server? It will help to understand your question– Peoplee
@Peoplee and Guilherme, I edited the question with the code I am using, I believe that now you can see the problem, the result of while repeats several Forms, but when I click on the Ubmit button it updates only the first form of the list generated by while
– Denis L. Murara
@Denisl.Murara as I said in the first comment, maybe Ajax is a better way out.
– Guilherme Nascimento
@Guilhermenascimento have some link to some tutorial I can send me?
– Denis L. Murara