In this script I loop the rows of a table, where each row contains a checkbox and hidden inputs.
The problem is that when I select a line with the checkbox, the values corresponding to the checkbox come correct plus the other inputs come as taking data from the unmarked lines
test.php
<formid="form2" name="form2" action="acao.php form=cotacao" method="POST">
<table>
<tr>
<td><input name="checkbox[]" type="checkbox" value="<?echo $id_produtos>"/>
</td>
<td><?echo $id_produtos?></td>
<td><input type="hidden" name="nome[]" value="<?echo $nome?>" /></td>
<td><input type="hidden" name="tipo_serv[]" value="<?echo $tipo_serv?>" />
</td>
<td><input type="hidden" name="valor[]"value="<?echo $valor?>" />
</td>
</tr><input type="submit" value="Gerar"/>
acao.php
if (isset($_POST['checkbox'])) {
foreach ($_POST['checkbox'] as $key => $value) {
echo $id_saida = mysql_real_escape_string($value);
$tipo = mysql_real_escape_string($_POST['tipo_serv'][$key]);
echo $nome = mysql_real_escape_string($_POST['nome'][$key]);
$start = mysql_real_escape_string($_POST['start'][$key]);
echo $valor = mysql_real_escape_string($_POST['valor'][$key]);
$desconto = mysql_real_escape_string($_POST['desconto'][$key]);
$tipo_veiculo=mysql_real_escape_string($_POST['tipo_veiculo'[$key]);