id nbsp;userid fld工作历史公司名称 fldWorkHistoryJoinedDate
1 nbsp nbsp nbsp;1 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;abc公司 nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp 2016.12.03
2 nbsp nbsp 1 nbsp nbsp nbsp nbsp nbsp nbsp nbsp def公司 nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp;2017.12.03
3 nbsp nbsp 1 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;ghi公司 nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp;2018.12.03
4 nbsp nbsp nbsp;2 nbsp nbsp nbsp nbsp nbsp nbsp nbsp;询问公司 nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp;2014.12.03
<input name="fldWorkHistoryCompanyName[]" type="text" class="form-control" placeholder="ABC Privet Limited 1" >
<input type="text" class="form-control" name="fldWorkHistoryJoiniedDate[]" >
<input name="fldWorkHistoryCompanyName[]" type="text" class="form-control" placeholder="ABC Privet Limited 2" >
<input type="text" class="form-control" name="fldWorkHistoryJoiniedDate[]" >
<input name="fldWorkHistoryCompanyName[]" type="text" class="form-control" placeholder="ABC Privet Limited 3" >
<input type="text" class="form-control" name="fldWorkHistoryJoiniedDate[]" >
如何在代码点火器中插入多个名称字段
为了使用单个名称在数据库中插入多个输入文本值。
您可以使用POST方法制作一个表单,并将这些字段放入表单中,当您提交按钮时,您可以将操作放入控制器中。
在控制器中,您可以进行
$history[] = $_Post['fldWorkHistoryCompanyName'];
foreach ($history as $key => $value) {
// make insert query and your value is in the $value variable.
}
或
如果你有活动记录,那么你可以这样做:
$data = array(
array(
'userid' => '1' ,
'fldWorkHistoryCompanyName' => 'Name' ,
'fldWorkHistoryJoinedDate' => 'My date'
),
array(
'userid' => '2' ,
'fldWorkHistoryCompanyName' => 'Another Name' ,
'fldWorkHistoryJoinedDate' => 'Another date'
)
);
$this->db->insert_batch('mytable', $data);
试试这个:
$fldWorkHistoryCompanyName = $this->input->post('fldWorkHistoryCompanyName');
foreach ($fldWorkHistoryCompanyName as $value) {
$data = array(
'field_name' => $value
);
$this->db->insert('tableName',$data);
}
您可以尝试此解决方案:
$i = 0
Foreach($fldWorkHistoryCompanyName as $key=>$value)
{
$data[$i]['fldWorkHistoryCompanyName'] = $value;
$data[$i]['fldWorkHistoryJoiniedDate'] = $fldWorkHistoryJoiniedDate[$key];
$i++;
}
$this->db->insert_batch('table_name',$data);