I can use insert batch in codeigniter but my problem is if I have 7 field in my form and i fill up 5 field in the form and submit I get 7 row in db. 5 row is ok but others 2row show sl no, date and invoice no. I want only 5 data which is fill up by form not others. my model is
public function purchase(){
$data = array(
array(
'date'=> $this->input->post('date'),
'vendor_name'=>$this->input->post('vendor_name'),
'model'=>$this->input->post('model'),
'price' =>$this->input->post('price'),
'purchase_quantity'=>$this->input->post('quantity'),
'amount' =>$this->input->post('price')*$this->input->post('quantity'),
'invoice_no'=>$this->input->post('invoice')
),
array(
'date'=> $this->input->post('date'),
'vendor_name'=>$this->input->post('vendor_name2'),
'model'=>$this->input->post('model2'),
'price' =>$this->input->post('price2'),
'purchase_quantity'=>$this->input->post('quantity2'),
'amount' =>$this->input->post('price2')*$this->input->post('quantity2'),
'invoice_no'=>$this->input->post('invoice')
),
array(
'date'=> $this->input->post('date'),
'vendor_name'=>$this->input->post('vendor_name3'),
'model'=>$this->input->post('model3'),
'price' =>$this->input->post('price3'),
'purchase_quantity'=>$this->input->post('quantity3'),
'amount' =>$this->input->post('price3')*$this->input->post('quantity3'),
'invoice_no'=>$this->input->post('invoice')
)
);
$insert = $this->db->insert_batch('purchase',$data);
return $insert;
}
Please help
you can use simple insert query on foreach
foreach ($data as $row){
$insert = $this->db->insert('purchase',$row);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.