我想是的,我有一个uniq的ID呼叫NUM我想插入多发说明了这一独特NUM.我有一个动态添加文件的表单,所以我可以添加我想要的字段.当我尝试插入一行数据时,当我尝试插入多个行数据时,它无法正常工作.
我的查看页面:
<form name="codexworld_frm" action="" method="post">
<div class="field_wrapper">
<input type="text" name="num" value=""/><br />
<input type="text" name="description[]" value=""/><input type="text" name="voucher_no[]" value=""/><input type="text" name="price[]" value=""/>
<a href="javascript:void(0);" class="add_button" title="Add field"><img src="<?php echo base_url('images/add-icon.png'); ?>"/></a>
</div>
<input type="submit" name="submit" value="SUBMIT"/>
</form>
Run Code Online (Sandbox Code Playgroud)
我的控制器:
$data = array(
'no' => $this->input->post('num'),
'descriptions' => $this->input->post('description'),
'voucher' => $this->input->post('voucher_no'),
'des_price' => $this->input->post('price'),
);
$this->multi_model->form_insert($data);
$data['message'] = 'Data Inserted Successfully';
//Loading View
$this->load->view('multi_view', $data);
Run Code Online (Sandbox Code Playgroud)
我的型号:
function form_insert($data){
$this->db->insert('tbl_description', $data);
}
Run Code Online (Sandbox Code Playgroud)
如果我使用foreache循环到我的模型我认为它会工作,但我如何使用? …
codeigniter ×1