Jump to content

list


jwilson122

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.