Hi, can you help me.. how to save value multiple dropdown

<select name="s1" id="s1" multiple="multiple">
<?php $sql=mysql_query("select * from setting_mp ORDER BY id_tingkat ASC");
while ($data=mysql_fetch_array($sql)){
echo "<option value=$data[id_mp]> $data[pelajaran]</option>";
} ?></select>

I wish if there are three values, then everything will go in the field
i want enter here :
table name = dbname
field name = id (autoincreament) and id_mp

Recommended Answers

All 7 Replies

you mean if there are three option tag then u want to store all in db? not the selected one?
Give example here what you want...

example : there are five option, i want the option selected (3 option) can be enter to field.
ok, thanks for your response sir, I have found a way. :icon_smile:
just add

foreach (array_expression as $key => $value)

before sql insert

if u want to get 3 values, better to use checkbox not use option

ok riskiana, thanks for your response, actually i have 45 option and I use multiple dropdown with checkboxes :)

ok riskiana, thanks for your response, actually i have 45 option and I use multiple dropdown with checkboxes :)

oh,,oke i see if u have 45 option, it's impossible to use checkboxes, not efective.
but i still not understand what's ur question?what u want ?:P

@ivanichi explain the problem clearly so we can help you

(@riskiana & @vaultdweller123)
++ ok friend, just look at this: http://sofanifani.com/download/jsave_dropdownlist/ if you select the option and pressing the submit button, the database will record the selected value

?? (how to save or record selected value)

** I have found a way (the problem is fix):
1. Retrieve POST data
2. Check if selections were made
3. Connect to database
4. foreach (array_expression as $key => $value)
5. sql insert.

http://sofanifani.com/download/save_dropdownlist.zip

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.