---Select--- ".$row['pack_-6ren">
gpt4 book ai didi

php - 将多项选择下拉列表保存到 1 列中

转载 作者:行者123 更新时间:2023-11-30 01:13:06 25 4
gpt4 key购买 nike

我想将多个下拉选择保存到数据库的一列中。

我有以下内容:

<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);

最佳答案

您忘记结束引用:

$qry = "Insert INTO tbl_packages (pack_choice) VALUES ('{$pack_choice}')";

是这样吗?如果不是,请分享您遇到的任何错误。

关于php - 将多项选择下拉列表保存到 1 列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19308708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com