abch624 Posted July 1, 2008 Share Posted July 1, 2008 Hi there, I have a html form like this <html> <body> <form method="post" action="testdo.php"> <SELECT NAME="toppings" MULTIPLE SIZE=5> <OPTION VALUE="mushrooms">mushrooms <OPTION VALUE="greenpeppers">green peppers <OPTION VALUE="onions">onions <OPTION VALUE="tomatoes">tomatoes <OPTION VALUE="olives">olives </SELECT> <input type="submit" value="hey"> </form> </body> </html> and the testdo.php file looks like this <?php $test=$_POST['toppings']; if ($test){ foreach ($test as $t){echo 'You selected '.$t.'<br />';} } ?> When I select and submit the form I get this error Warning: Invalid argument supplied for foreach() in C:\wamp\www\1STA\testdo.php on line 4 This might be silly but I need help guys. Please - Zahid Link to comment https://forums.phpfreaks.com/topic/112756-solved-multi-select-with-php/ Share on other sites More sharing options...
abch624 Posted July 1, 2008 Author Share Posted July 1, 2008 Hi Guys, This works now. the name of the form has to be an array!!!! Cheers - Zahid Link to comment https://forums.phpfreaks.com/topic/112756-solved-multi-select-with-php/#findComment-579080 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.