I am trying to insert a batch of rows for wholesale, dealer and customer Note : i am using 'append' to add row of inputs but then they carry the same input names. I am trying to apply this to wholesale first but it is not happening when i add another row to my wholesale input list it is taking only one row(my last row) input and my other row of inputs are discarded. the var_dump of array reveals that.
This is my controller file
$range = $this->input->post('wrange1');
$usertype = $this->input->post('wusertype');
$uom = $this->input->post('wuom1');
$price = $this->input->post('wamount1'); //array of price
$vat = $this->input->post('wvat1');
var_dump($range);// i am getting only one output
$updateArray = [];
for($x = 0; $x < sizeof($price); $x++){
$updateArray[$x] = array(
'product_id'=> $id,
'range' => $range[$x],
'usertype' => $usertype[$x],
'uom' => $uom[$x],
'price' => $price[$x],
'vat' => $vat[$x]
);
}
$this->productmodel->updatepricinglist($updateArray);
This is my model file:
public function updatepricinglist($updateArray) {
$this->db->insert_batch('product_pricing', $updateArray);
}