I'm using ajax to post my json data ( to ci controller )
and then json_decode
to read my data.
this data from table
Array
(
[Detail] => Array
(
[0] => Array
(
[row0] => Array
(
)
)
[1] => Array
(
[row1] => Array
(
[0] => Array
(
[cell0] => 04019
)
[1] => Array
(
[cell1] =>
)
[2] => Array
(
[cell2] => 2.00
)
[3] => Array
(
[cell3] =>
)
[4] => Array
(
[cell4] => 4530000
)
[5] => Array
(
[cell5] =>
)
[6] => Array
(
[cell6] =>
)
)
)
)
)
I want to read data and update the database using the ci model
$data = array(
'Customer' => $this->input->post('Customer'),
'Total' => $this->input->post('Total'),
'Detail' => $this->input->post('Detail')
);
$json = json_decode($data['Detail'],true);
$Sql ="";
$row=0;
foreach ($json as $doc)
{
if ($row !=0)
{
$Sql .= ' Insert Detail' + $doc[0]->cell0 . ' ' . $doc[2]->cell2 . ' ' . $doc[4]->cell4;
}
$row++;
}
print_r($Sql);
but it's not working,
How to read the data array and save it to the Sql
var. Thanks