({ status:'ok', table:{ cols:[ {id:'Col1',label:'time',type:'date'}, {id:'Col2',label:'in',type:'number'}, {id:'Col3',label:'out',type:'number'} ], rows:[ query('SELECT * FROM network LIMIT (SELECT count(*) FROM network) -24, 24;') as $row) { echo "\t\t{c:[{v:new Date({$row['time']}000),f:'".date('G', $row['time'])."'},{v:{$row['rx']}},{v:{$row['tx']}}]},\n"; } } elseif($_GET['data'] == 'cpu') { ?> table:{ cols:[ {id:'Col1',label:'time',type:'date'}, {id:'Col2',label:'usage',type:'number'} ], rows:[ query('SELECT * FROM cpu LIMIT (SELECT count(*) FROM cpu) -24, 24;') as $row) { echo "\t\t{c:[{v:new Date({$row['time']}000),f:'".date('G', $row['time'])."'},{v:{$row['usage']}}]},\n"; } } } catch(PDOException $e) { echo $e->getMessage(); } ?> ]} })