The HTML:
<form method="post" action="form.php">
<input type="checkbox" name="foo[]" value="1"/>This<br/>
<input type="checkbox" name="foo[]" value="3"/>That<br/>
<input type="checkbox" name="foo[]" value="4"/>Those<br/>
<input id="btnClick" type="submit" />
</form>
The PHP:
foreach ($_POST['foo'] as $va)
{
$stmt1 = $conn->prepare("select sum(field) from table where field2 in ($va)");
$stmt1->execute($data1);
$result1 = $stmt1->fetchAll();
print_r(var_dump($va));
...
}
The problem:
This let me do the query only when I select one checkbox, if I select 2 or more, it just takes the last selected value.
What am I missing there?
Thanks in advance.