Php 在代码点火器中插入阵列柱

Php 在代码点火器中插入阵列柱,php,mysql,arrays,codeigniter,Php,Mysql,Arrays,Codeigniter,我必须按如下方式将数据插入表中: 在一个请求中,有许多人将被包括在请求中。 现在,我已经完成了插入请求信息的工作。 我在将人员信息与请求id一起插入到request_details表时遇到问题 例如: 在请求表中: Request table Request ID | Description 1 | sample1 Request Details Req_det_id | Request ID | Person |Quantity 1

我必须按如下方式将数据插入表中: 在一个请求中,有许多人将被包括在请求中。 现在,我已经完成了插入请求信息的工作。 我在将人员信息与请求id一起插入到request_details表时遇到问题

例如:

在请求表中:

Request table
Request ID  |  Description
1           |  sample1


Request Details
Req_det_id    |   Request ID  |  Person    |Quantity
1             |     1         |  P1        | 10
2             |     1         |  P2        |20
如何将数组插入到请求详细信息表中

我认为:

<div id="show" style="display:none;">
    <select name="hhname[]" value="" id="drop2"  style="color:black;">
            <?php
                foreach ($head as $row) {
                    echo "<option style='color:black;' value='".$row['hh_id']."'>".$row['hh_fname']."  ".$row['hh_lname']."</option>";
                                            }
                          ?>
    </select>
    <input type="text" placeholder="Quantity" name="quant[]" value="">
</div>

非常感谢您的帮助。

创建一个新的关联数组,并将该关联数组推送到另一个数组中,然后使用此->db->insert\U batch('表\u名称',要插入的批\u数组)

例如。 控制器:

$req_data = array(
            'requestor_id' => $input['requestor_id'],
            'request_package_id' => $r_id,
            'request_place' => $input['request_place'],
            'request_date' => $input['request_date'],
            'request_remarks' => $input['request_remarks'],
            'request_specify' => $input['request_specify'],
            'request_quantity' => $input['request_quantity'],
            'request_status' => 1,
            'request_code' => "fsdf2324",

        );
        $request_id = $this->CreateRequest_model->addReq($req_data);
        $this->CreateRequest_model->updatePackTable($input['package_id']);

        $name = $input['hhname']; // this is already an array
        $quant = $input['quant']; // this is an array

        foreach ($name as $row ) {
            $data = array(
                //how should i insert it to the req details table?
            );
        }
$name = $input['hhname']; // this is already an array
$quant = $input['quant']; // this is an array
$cnt = count($name);
$cnt1 = count($quant);
 $push_arr = array();
for($i=0; $i<$cnt && $i<$cnt1; $i++)
{
  $tmp_arr = array('$request_id' => $request_id,
                   'Person'=> $name[$i],
                   'Quantity'=>$quant[$i]);
 array_push($push_arr,$tmp_arr);
}
$this->Your_model->insert_request_details($push_arr);

哇!成功了!非常感谢你,你救了我的命,兄弟。
function insert_request_details($push_arr)
{
   $val = $this->db->insert_batch('Request Details',$push_arr);
   return val;
}