Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在采购订单表单中插入多个带有多个其他变量的“product”_Php_Mysql_Arrays_Mysqli - Fatal编程技术网

Php 如何在采购订单表单中插入多个带有多个其他变量的“product”

Php 如何在采购订单表单中插入多个带有多个其他变量的“product”,php,mysql,arrays,mysqli,Php,Mysql,Arrays,Mysqli,我有10行以下代码在我的采购订单形式。其中用户手动添加值 <input type="text" name="name[]" /> <input type="text" name="code[]" /> <input type="text" name="rate[]" /> <input type="text" name="tax[]" /> <input type="text" name="amount[]" /> 上面的代码将组合所

我有10行以下代码在我的采购订单形式。其中用户手动添加值

<input type="text" name="name[]" />
<input type="text" name="code[]" />
<input type="text" name="rate[]" />
<input type="text" name="tax[]" />
<input type="text" name="amount[]" />
上面的代码将组合所有的名称,但我希望其中有一行的值,如

array ("name" => Product 1, "code" => P30, "rate" => 1000, "tax" => 12, "amount" => 1120)
然后在插入查询中提交它。

$output=[];
$output = [];
  for($i=0;$i<count($name);$i++){
      $data['name'] = $name[$i];
      $data['code'] = $code[$i];
      ...

      $output[] = $data;
  }
对于($i=0;$i
$output=[];

对于($i=0;$i)它将忽略空输入值,还是需要添加if(empty($\u POST($name)),如果是,那么如何将其添加到上述循环中。是的,您需要在处理此循环之前进行空验证。它将忽略空输入值,还是需要添加if(empty($\u POST($name))如果是,那么如何将其添加到上面的循环中。是的,您需要在处理此循环之前进行空验证。
$output = [];
  for($i=0;$i<count($name);$i++){
      $data['name'] = $name[$i];
      $data['code'] = $code[$i];
      ...

      $output[] = $data;
  }