multiple selection insert to DB

Dear all

I have use DW making a PHP site and has set a multiple selection
field..But I don't know how to write the SQL statement to database like

<select name="support[]" size="3" multiple="multiple" id="support">
<option value="1">Apple</option>
<option value="2">Orange</option>
<option value="3">Banana</option>
<option value="4">Watermelon</option>
</select>

If I choose 1 & 4, my database table will capture to array..I want the
DB can be caapture the 1,4, please teach me how to do this.(I know
array is a vars but i don't know how to write the statement)

BTW..If I would like recall this field to display. how to do it

Many thanks again

Ace
Ace [ Fr, 29 Dezember 2006 07:54 ] [ ID #1580431 ]

Re: multiple selection insert to DB

Ace wrote:
> Dear all
>
> I have use DW making a PHP site and has set a multiple selection
> field..But I don't know how to write the SQL statement to database like
>
> <select name="support[]" size="3" multiple="multiple" id="support">
> <option value="1">Apple</option>
> <option value="2">Orange</option>
> <option value="3">Banana</option>
> <option value="4">Watermelon</option>
> </select>
>
> If I choose 1 & 4, my database table will capture to array..I want the
> DB can be caapture the 1,4, please teach me how to do this.(I know
> array is a vars but i don't know how to write the statement)

Much depends on how you want to store the data

One line, comma between entries:
$theline=implode(',',$_REQUEST['support']);

Do something for each entry:
for($i=0;$i<count($_REQUEST['support']);$i++) {
$currentvalue=$_REQUEST['support'][$i];
/* do what you want with the $currentvalue */
}


> BTW..If I would like recall this field to display. how to do it

The above for loop.

--

//Aho
Shion [ Fr, 29 Dezember 2006 09:03 ] [ ID #1580433 ]
PHP » alt.php.sql » multiple selection insert to DB

Vorheriges Thema: Need Consultant to Help with CakePHP
Nächstes Thema: Can this Query be made faster?