我想将多个下拉选择保存到数据库中的一列中。
我有以下内容:
<select name="pack_choice[]" style="width:270px; margin-bottom:2px;">
<option value=''>---Select---</option>
<?php
$query = mysql_query("SELECT * FROM tbl_package_source where pack_type = 'Bronze' AND pack_desc = 'Pasta/Noodles/Vegetables'");
while ($row = mysql_fetch_array($query)){
$pack_id = $row['pack_code'];
echo "<option value='".$row['pack_code']."'>".$row['pack_part']."</option>";
} ?>
</select>
<select name="pack_choice[]" style="width:270px; margin-bottom:2px;">
<option value=''>---Select---</option>
<?php
$query1 = mysql_query("SELECT * FROM tbl_package_source where pack_type = 'Bronze' AND pack_desc = 'Seafoods'");
while ($row = mysql_fetch_array($query1)){
$pack_id = $row['pack_code'];
echo "<option value='".$row['pack_code']."'>".$row['pack_part']."</option>";
}
?>
</select><br/>
这是我的查询
$pack_choice = implode(", ",$_POST['pack_choice']);
$qry = "Insert INTO tbl_packages (pack_choice) VALUES ('{$pack_choice}')";
$result_set = mysql_query($qry);