With this script, written in short because you know better than I do.
<?php
$query = "select from table where status='0'";
$i=0;
while (mysqli_fetch_array)
echo '<input type="hidden" value="' . $num_compra . '" name="item['.$i.'][num_compra]" />
<input type="hidden" value="'.$plano.'" name="item['.$i.'][plano]">';
$i++;
?>
I got this:
<html>
<input type="hidden" value="1111" name="item[0][num_compra]" />
<input type="hidden" value="aaaa" name="item[0][plano]" >
<input type="hidden" value="2222" name="item[1][num_compra]" />
<input type="hidden" value="bbbb" name="item[1][plano]" >
<input type="hidden" value="3333" name="item[2][num_compra]" />
<input type="hidden" value="cccc" name="item[2][plano]" >
quantidade de pares de input de acordo com o banco de dados.
<input type="submit">
</html>
After SUBMIT:
echo $_POST['item'];
Array ( [0] => Array ( [num_compra] => 1111 [plano] => aaaa )
[1] => Array ( [num_compra] => 2222 [plano] => bbbb )
[2] => Array ( [num_compra] => 3333 [plano] => cccc ) )
So far so good, now the problem : I need to put a checkbox for each input
<input type="hidden" value="1111" name="item[0][num_compra]" />
<input type="hidden" value="aaaa" name="item[0][plano]" >
<INPUT TYPE="CHECKBOX" NAME="????" VALUE="?????"> CHECKBOX 1
<input type="hidden" value="2222" name="item[1][num_compra]" />
<input type="hidden" value="bbbb" name="item[1][plano]" >
<INPUT TYPE="CHECKBOX" NAME="?????" VALUE="?????"> CHECKBOX 2
<input type="hidden" value="3333" name="item[2][num_compra]" />
<input type="hidden" value="cccc" name="item[2][plano]" >
<INPUT TYPE="CHECKBOX" NAME="?????" VALUE="????"> CHECKBOX 3
and create an array only with checkbox = checked
CHECKBOX 3 checked
Array ( [0] => Array ( [num_compra] => 3333 [plano] => cccc ) )
CHECKBOX 2 and CHECKBOX 3 checked
Array ( [0] => Array ( [num_compra] => 2222 [plano] => bbbb )
[1] => Array ( [num_compra] => 3333 [plano] => cccc ) )
CHECKBOX 1 and CHECKBOX 3
Array ( [0] => Array ( [num_compra] => 1111 [plano] => aaaa )
[1] => Array ( [num_compra] => 3333 [plano] => cccc ) )
and in the end, use this array to do
UPDATE table SET status='1' WHERE num_compra = $num_compra AND plano = $plano;
What is the solution to this?