PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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
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
<?php
if (isset($_POST)){
foreach($_POST as $key=>$value){print $key." ".$value."<br>";}
}
?>
Notice that I have removed "exit" from your code. You can't have "exit" inside a foreach statement, since it would force to exit the file at the first iteration.
manohoo wrote:$_POST['bx'] is not an array, so you can't use foreach.
Actually, if you look at the code, $_POST['bx'] is an array, but $bx is not, it's Undefined.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.