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 :
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