Server Side Processing Array
Server Side Processing Array
Hello, I have a question about the syntax of the array before use the json encode function.
I'm using codeigniter as framework, I'm getting an object array from the query like this.
** print_r($data); **
Array
(
[0] => stdClass Object
(
[ID] => 1
[Partnum] => 00505
[Partnum_description] => XXXX
)
)
When following the syntax I'm doing this, I'm getting the following error
Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
$json_data = array(
"draw" => intval($_REQUEST['draw']),
"recordsTotal" => count($data),
"recordsFiltered" => count($data),
"data" => $data
);
echo json_encode($json_data);
so I created a new array without object, I'm not getting anymore the error but the results are not shown
my code is like this
foreach($data as $index => $k)
{
$values = array (
'ID' => $k->ID,
'Partnum' => $k->Partnum,
'Partnum_description' => $k-> Partnum_description
);
}
$json_data = array(
"draw" => intval($_REQUEST['draw']),
"recordsTotal" => count($values),
"recordsFiltered" => count($values),
"data" => $values
);
echo json_encode($json_data);
How should be the array format in order to use the json encode function?, thank you.