我有一個動態輸出窗體,其中文本輸入字段具有相同的名稱。我需要通過 循環輸入文本併爲數據庫中的每個文本字段輸入插入多行。通過窗體輸入數組循環
$sql="INSERT INTO orderitems (orderNum,productNum,quant)
VALUES
('$num1','$_POST[pNum]','$_POST[quant]')";
<input type="text" name="pNum" value="<?php echo $t1; ?>"> //may have several with same name
你必須給這些字段命名爲'pNUm []',否則PHP無法處理具有相同名稱的多個字段。看看這裏:http://php.net/manual/en/language.variables.external.php – 2010-10-13 13:07:46