"foreach" help needed
Posted: Sun Jan 03, 2010 12:48 pm
Try as I might I can not get this to work. The checkboxes display properly. On submit I should get a list of the position (0, 1, 2) of each or all the boxes that are checked. (If B and C checked should get...
1
2
Instead I get
Here's the code...
As always, your patience with a newbie is appreciated.
1
2
Instead I get
--------------Notice: Undefined variable: bx in /Applications/MAMP/htdocs/test4.php on line 4
Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/test4.php on line 4
Here's the code...
Code: Select all
<?php
if (isset($_POST['bx'])){
foreach($bx as $this){print $this."<br>";}
exit();
}
?>
<html>
<form action="test4.php" method="POST">
<?php
$list[]="A";
$list[]="B";
$list[]="C";
$nbrInList=count($list);
for ($i=0;$i<=2;$i++)
{
print $list[$i];
print "<input name=\"bx[]\" type=\"checkbox\" value=\"$i\"><br>";
}
?>
<input type='submit'>
</form>
</html>