Jump to content

[SOLVED] Multi Select with PHP


abch624

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.