帮忙。 我想插入数据库Urunler []。但它没有让它发挥作用。
<select name="urunler[1]"> <option selected="" value="DF-12">DF-12</option></select>
<select name="urunler[2]"> <option selected="" value="DF-5">DF-5</option></select>
<select name="urunler[3]"> <option selected="" value="DF-15">DF-15</option></select>
$urunler = array();
$values = array();
foreach($_POST[$urunler] as $key => $urun_value) {
$values[] = "('" . mysql_real_escape_string($urun_value) . "')";
}
$val_string = implode(',', $values);
$ekle = mysql_query (
"INSERT INTO siparis_onay (
id,urunkodu,urunfiyat,uadet,ekurun)
VALUES ('$id','$urunkodu','$urunfiyat','$uadet','$val_string')
");
答案 0 :(得分:0)
<select name="urunler[]">
<option value="DF-5">DF-5</option>
<option value="DF-12">DF-12</option>
<option value="DF-1">DF-1</option>
</select>
<?php
foreach ($_POST['urunler'] as $key => $value) {
$values[] = "('" . mysql_real_escape_string($value) . "')";
}
$val_string = implode(',', $values);