通过Ajax表单提交,通过在DB中用逗号分隔的一行中插入多个选项,但是内容给出错误

I have a Ajax form that is submitting data into my MySQL database.

I have select2 boxes that allow users to select multiple choices.

Here is an example of one box's HTLM code:

<select class="select3 form-control select2-multiple track" name="sellingmethods" id ="sellingmethods" multiple="multiple" multiple data-placeholder="Choose ...">
    <option value="Telesales">Telesales</option>
    <option value="Party Planning">Party Planning</option>
    <option value="Door to Door">Door to Door</option>
    <option value="Face to Face">Face to Face</option>
    <option value="Online Demos">Online Demos</option>
    <option value="Affiliate Link">Affiliate Link</option>
    <option value="Appointment Setting">Appointment Setting</option>
</select>

When I click submit it passes the data like this :

Example Ajax Post Data

As you can see it posts the same id of the box multiple times example seen on selling methods.

At the moment my PHP code that puts it in the DB is only putting the last item into the database.

Is there a way to put the multiple selections in separated by a comma? For example "door to door,telesales".

Here is my current PHP code :

'sellingmethods' => implode(',', $this->input->post('sellingmethods')),
'sellertype' => implode(',', $this->input->post('sellertype')),
'want2sell' => implode(',', $this->input->post('want2sell')),
'productssold' => implode(',', $this->input->post('productssold')),
'industriesrepresented' => implode(',', $this->input->post('industriesrepresented')),

Which is currently giving me the error :

implode(): Invalid arguments passed

To access the multiple options submitted through a select multiple as an array, you will need to set the name attribute as an array eg sellingmethods[]

So for example:

<select class="select3 form-control select2-multiple track" name="sellingmethods[]" id ="sellingmethods" multiple="multiple" multiple data-placeholder="Choose ...">

 <option value="Telesales">Telesales</option>
 <option value="Party Planning">Party Planning</option>
 <option value="Door to Door">Door to Door</option>
 <option value="Face to Face">Face to Face</option>
 <option value="Online Demos">Online Demos</option>
 <option value="Affiliate Link">Affiliate Link</option>
 <option value="Appointment Setting">Appointment Setting</option>
</select>

Then $this->input->post('sellingmethods') or $_POST['sellingmethods'] will be an array as expected, and you should no longer get the error for your implode() function.