Jump to content

Multi List Selection PHP


mattyt81

Recommended Posts

Hi

 

I am pulling my hair out over this, I have tried many many ways on getting this to work but none have.

 

I have a multi list selection box, which the user can select more than one option from. Once submitted this gets sent to a mysql database table.

 

Below is my shortened version of the multi list html code:

 

<select multiple="multiple" size="10" name="special[]">

<option value="Abdominal Training"> Abdominal Training </option>

                        <option value="Aerobics"> Aerobics </option>

                        <option value="Agility"> Agility </option>

 

</select>

 

 

If have tried putting  [] which creates an array in the mysql table field special, but when I echo it back it just echos 'array'.

 

When I try it without the [], and echo it back, it only echos one selection.

 

I am still new to php, but have managed to get my head around a lot, but have been stuck on this for weeks, please help.

Link to comment
Share on other sites

If have tried putting  [] which creates an array in the mysql table field special

No, it creates an array in PHP. $_POST["special"] is an array. You have to add each item in that array into your database.

 

I suspect a problem with that part. What does your database look like? How do you plan on storing these multiple values?

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.