2
I have the code below and I want the array
nome
contains only the names of the lines that have the checkbox
cb
marked.
<form action="" method="post">
<table>
<tr>
<td><input type="checkbox" name="cb[]" id="cb1" value="1"></td>
<td><input type="text" name="nome[]" id="nome1"></td>
</tr>
<tr>
<td><input type="checkbox" name="cb[]" id="cb2" value="1"></td>
<td><input type="text" name="nome[]" id="nome2"></td>
</tr>
<tr>
<td><input type="checkbox" name="cb[]" id="cb3" value="1"></td>
<td><input type="text" name="nome[]" id="nome3"></td>
</tr>
</table>
<input type="submit" value="enviar" name="enviar">
</form>
<?php
if (isset($_POST['enviar'])) {
var_dump($_POST['cb']);
var_dump($_POST['nome']);
}
?>
I tried that way and it didn’t work. Thus the code: $name = array(); for ($i = 0; $i < Count($_POST['cb']); $i++) { if(isset($_POST['cb'][$i])) { $name[]= $_POST['name'][$i]; } } var_dump($name);
– Lucas