jwilson122 Posted January 19, 2011 Share Posted January 19, 2011 Hey, I'm having a issue with using a listbox.. Am I doing something wrong?? Heres my HTML: <select style="height:100px;width:250px;" name="countries[]" multiple> <option value="US">United States</option> <option value="UK">United Kingdom</option> <option value="CA">Canada</option> <option value="AU">Australia</option> </select> and my PHP: $countries = $_POST['countries']; $countries = implode(' | ', $countries); I'm trying to set it up so I can insert the data as: US | UK | CA. But, when I submit the form, I get these errors: Notice: Undefined index: countries in /Applications/MAMP/htdocs/mynewscript/admin/cp/add.php on line 30 Warning: implode() [function.implode]: Invalid arguments passed in /Applications/MAMP/htdocs/mynewscript/admin/cp/add.php on line 31 Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/224973-list/ Share on other sites More sharing options...
taquitosensei Posted January 19, 2011 Share Posted January 19, 2011 do print_r($_POST); just before you set the $countries this will tell you whether it's being posted or not. Everything looks correct. But it's possible you didn't set your form to post. Or this is outside of the form. Quote Link to comment https://forums.phpfreaks.com/topic/224973-list/#findComment-1161961 Share on other sites More sharing options...
jwilson122 Posted January 19, 2011 Author Share Posted January 19, 2011 do print_r($_POST); just before you set the $countries this will tell you whether it's being posted or not. Everything looks correct. But it's possible you didn't set your form to post. Or this is outside of the form. Its posting it fine.. The array is posting out: => [countries] and it is inside the form, and I have it wrapped with a if isset statement. I've done it before, worked fine. Not exactly sure why its not working. Quote Link to comment https://forums.phpfreaks.com/topic/224973-list/#findComment-1161964 Share on other sites More sharing options...
TOA Posted January 19, 2011 Share Posted January 19, 2011 Check here http://www.w3schools.com/tags/att_select_multiple.asp Quote Link to comment https://forums.phpfreaks.com/topic/224973-list/#findComment-1161976 Share on other sites More sharing options...
taquitosensei Posted January 20, 2011 Share Posted January 20, 2011 you have the brackets after countries. So you're countries would be index 0 of $_POST['countries'] drop the brackets or refer to $_POST['countries'][0]; Quote Link to comment https://forums.phpfreaks.com/topic/224973-list/#findComment-1162340 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.