Change
SELECT c.one, c.two FROM table c
to
SELECT c.one as key1, c.two as key2 FROM table c
Then encapsulate the results in json (after foreach):
echo json_encode(array(
'result'=>$arr
));
But you will most likely need a loop through them in jquery.
Your json output will look something like this:
result: [
{'key1': 'asd', 'key2': 'qwe'},
[...]
{'key1': 'asd', 'key2': 'qwe'}
]
Scroll them like this:
console.log(json.result);
jQuery.each( json.result, function( i, subresult ) {
console.log(subresult);
});
source
share