无法在数据库PHP中插入多数组

时间:2019-07-11 09:30:20

标签: php mysqli codeigniter-3

我正在写代码,将3个输入值形式保存到数据库中。但代码无法正常工作

这是我的html表单代码

我尝试插入这3个附加值,并且我要将此表格附加3次

<select name="fldCustomerFormPaxRoomsAdult[]" ><option value="1">1</option><option value="2" selected>2</option>
<select name="fldCustomerFormPaxRoomsChild[]" ><option value="0" selected>0</option><option value="1">1</option><option value="2">2</option>
<select name="fldCustomerFormPaxRoomsInfant[]" ><option value="0" selected>0</option><option value="1">1</option><option value="2">2</option>

<select name="fldCustomerFormPaxRoomsAdult[]" ><option value="1">1</option><option value="2" selected>2</option>
<select name="fldCustomerFormPaxRoomsChild[]" ><option value="0" selected>0</option><option value="1">1</option><option value="2">2</option>
<select name="fldCustomerFormPaxRoomsInfant[]" ><option value="0" selected>0</option><option value="1">1</option><option value="2">2</option>
<pre>
    $count = '2';

     $data5 = array();   
    for ($i = 0; $i < count($count); $i++) { 
        $data5[] = array(
            'fldCustomerFormPaxRoomsAdult' => $this->input->post('fldCustomerFormPaxRoomsAdult')[$i],
            'fldCustomerFormPaxRoomsChild' => $fldCustomerFormPaxRoomsChild[$i],
            'fldCustomerFormPaxRoomsInfant' => $fldCustomerFormPaxRoomsInfant[$i]
        );
    }echo '<pre>';
    var_dump($data5);
    echo'</pre>';
    die;

这是我的var_dump代码

array(1){[0]=>array(3){["fldCustomerFormPaxRoomsAdult"]=>
    string(1) "2"["fldCustomerFormPaxRoomsChild"]=>string(1) "2"["fldCustomerFormPaxRoomsInfant"]=>string(1) "2"}}

这是我的预期结果

array(1){[0]=>array(3){["fldCustomerFormPaxRoomsAdult"]=>
    string(1) "2"["fldCustomerFormPaxRoomsChild"]=>string(1) "2"["fldCustomerFormPaxRoomsInfant"]=>string(1) "2"}{[1]=>array(3){["fldCustomerFormPaxRoomsAdult"]=>
    string(1) "1"["fldCustomerFormPaxRoomsChild"]=>string(1) "1"["fldCustomerFormPaxRoomsInfant"]=>string(1) "1"}}

0 个答案:

没有答案