I'm not experienced with json_encode and am trying to return an arrray of array which should be called aaData - for DataTables with server-side processing.
The output should be like:
{
"sEcho": 3,
"iTotalRecords": 57,
"iTotalDisplayRecords": 57,
"aaData": [
[
"Gecko",
"Firefox 1.0",
"Win 98+ / OSX.2+",
"1.7",
"A"
],
[
"Gecko",
"Firefox 1.5",
"Win 98+ / OSX.2+",
"1.8",
"A"
],
...
]
}
but the actuall output of my PostgreSQL 8.4-driven PHP-script
if (isset($_REQUEST['json'])) {
$aaData = array();
while ($row = $sth->fetch(PDO::FETCH_NUM)) {
array_push($aaData, $row);
}
print json_encode($aaData);
}
is actually missing outside brackets (object like?) and the aaData name:
[
[ .... ],
[ .... ],
[ .... ]
]
How would you do this best?