chelnov63 Posted May 13, 2009 Share Posted May 13, 2009 How i was just wondering, how do I gather the info selected in a list box on the php page to which the form is submitted.. e.g the form is: <form action="add_contact.php" method="post"> <SELECT name = "contacts" MULTIPLE SIZE=5 > <OPTION VALUE="o1">Option 1 <OPTION VALUE="o2">Option 2 <OPTION VALUE="o3">Option 3 <OPTION VALUE="o4">Option 4 <OPTION VALUE="o5">Option 5 <OPTION VALUE="o6">Option 6 </SELECT> </form> How would I gather which values were selected when the form is submitted..thanks in advance Link to comment https://forums.phpfreaks.com/topic/157940-gathering-info-from-listbox/ Share on other sites More sharing options...
chelnov63 Posted May 13, 2009 Author Share Posted May 13, 2009 I've tried doing: <?php $values = $_POST['contacts']; foreach($values as $key) { echo $key."<br>"; } ?> however I get the error: Warning: Invalid argument supplied for foreach() in C:\htdocs\ABC\ on line 7 Link to comment https://forums.phpfreaks.com/topic/157940-gathering-info-from-listbox/#findComment-833076 Share on other sites More sharing options...
chelnov63 Posted May 13, 2009 Author Share Posted May 13, 2009 got it name="contacts" should be name = "contacts[]" Link to comment https://forums.phpfreaks.com/topic/157940-gathering-info-from-listbox/#findComment-833079 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.