2 Votes Vote

Handling data from multiple select field

Posted by topdog 198 days ago Questions| option select multiple All

I have a multiple select field designed as below:

<select name="deductions[]" multiple="multiple">
<option>Option 1</option>
<option>Option 2</option>
<option>.......</option>
</select>

I want to get values from the above select field to db using php post.This is how I have done it

<?php
$deds=$_POST['deductions'];
$deds_joined=join(',',$deds);
$sql=mysql_query("insert into mytable(deduction) values($deds_joined)");
/*code continues*/

My interest is to get the deduction values to an array and store it in db in this manner: value1,value2,value3. Unfortunately I have not been able to achieve this.Instead only a single value of the intended array is obtained. Your assistance will be highly appreciated.Thanks.

Originally asked by: Kiu Felix on Stack Overflow

Discuss Bury


Who Voted for this Question