Reputation: 13
i want to ask. I made an automatic code that I will post to the database, but I have problems, the data does not enter the database.
here I make an automatic code for item code
$data['awb'] = $this->M_order->bikin_kode();
I want to enter the value into 'tracking_number'
$data['awb'] = $this->M_order->bikin_kode();
$resinya = $data['awb'];
$sheet = $loadexcel->getActiveSheet()->toArray(null, true, true ,true);
$data = array();
$numrow = 1;
foreach($sheet as $row){
if($numrow > 1){
array_push($data,
array(
'tracking_number' => $resinya['awb'],
)
);
}
$numrow++;
}
$this->M_order->insert_multiple($data);
when I insert the data it doesn't enter
Upvotes: 0
Views: 60
Reputation: 165
I think you have passing data wrongly to array. Use $data['awb']
instead of $resinya['awb']
for 'tracking_number'.like this
array_push($data,
array(
'tracking_number' => $data['awb'],
)
);
Now, your code insert the data outside the foreach. so it will execute the last data into the database table.
Upvotes: 1