I have no trouble at all outputting MySQL data to an array then encoding in json.
What I am trying to understand is how can I add to this json output other pieces of non-dynamic data.
if (mysql_num_rows($result) > 0) {
while($obj = mysql_fetch_object($result)) {
$arr[] = $obj;
}
echo $_GET['callback'].'('.json_encode($arr).')';
}else{
}
What I need for example is to add something like
"firstnumber":"0"
"secondnumber":"10"
Is there a way to successfully add this form of data with the array of results and encode it all?
$_GET['callback']makes this code vulnerable to a form of cross site scripting attack. The client can inject javascript code into your system. You must validate/sanitize$_GET['callback']before echoing it back to the client.