更新时间:2021-09-03 23:20:36
您尝试分配一个具有相同名称的值.因此,最后一个值将替换为现有值.
You try to assign a value with same name.so your last value replace with the existing value.
例如:您的URL看起来像
for example :your URL look like,
http://www.example.com/index.php?finished_product_name=abc&material_name=xxx&finished_product_name=pqr&material_name=yyy
所以您的$_GET['finished_product_name']
的值是pqr
而不是abc
.
so your $_GET['finished_product_name']
has value is pqr
not abc
.
如果您可以使用include []
更改字段名称,则PHP将创建一个包含所有匹配值的数组:
If you can change the field name with include []
, then PHP will create an array containing all of the matching values:
http://www.example.com/index.php?id[]=123&version[]=3&id[]=234&version[]=4
您的网址示例,
http://www.example.com/index.php?finished_product_name[]=abc&material_name[]=xxx&finished_product_name[]=pqr&material_name[]=yyy
您的for循环是:
for ($i=0; $i < count($_POST['finished_product_name']); $i++ )
{
$product =$_POST['finished_product_name'][$i];
$material = $_POST['material_name'][$i];
$quantity = $_POST'product_quantity'][$i];
}