[英]json encode php and google charts
$data = '{
"cols": [ {"id":"","label":"ID","pattern":"","type":"string"},
{"id":"","label":"Instant Background","pattern":"","type":"number"},
{"id":"","label":"Red","pattern":"","type":"number"},
{"id":"","label":"Green","pattern":"","type":"number"},
{"id":"","label":"Blue","pattern":"","type":"number"}
],
"rows": [
{"c":[{"v":"827075"},{"v":3992},{"v":3989},{"v":3994},{"v":3993}]},
{"c":[{"v":"827070"},{"v":3974},{"v":3987},{"v":3985},{"v":3985}]},
{"c":[{"v":"827070"},{"v":3974},{"v":3987},{"v":3985},{"v":3985}]},
{"c":[{"v":"827070"},{"v":3974},{"v":3987},{"v":3985},{"v":3985}]},
{"c":[{"v":"827070"},{"v":3974},{"v":3987},{"v":3985},{"v":3985}]}
]
}'; echo $data;
ok the data works witht the echo when used on the google maps in this format so there is no issue there. 好的,当以这种格式在Google地图上使用时,数据可以与回波一起工作,因此那里没有问题。
function drawChart(jsonData) {
jsonData = $.ajax({
url: "http://www.mailboxmbe.com/jsongraph.php",
dataType:"json",
async: false
}).responseText;
PHP gets the data from an SQl statement and constructs the data as such: PHP从SQl语句获取数据并按以下方式构造数据:
$JSONObject1 = '{"c":[{"v":"'.$row["id"].'"},{"v":'.$row["sinstantBackground"].'},{"v":'.$row["sRed"].'},{"v":'.$row["sGreen"].'},{"v":'.$row["sBlue"].'}]},'.$JSONObject1;
Each Row has the following id,sinstantBackground,sRed,sGreen.sBlue. 每个行具有以下id,sinstantBackground,sRed,sGreen.sBlue。
On the the Graph page jsonData holds the json string passed to it from the echo $data which is called via the SQL query. 在“图形”页面上, jsonData包含通过echo $ data传递给它的json字符串,该字符串通过SQL查询被调用。
What I would like to do is work out how to turn the json script in jsonData into a format where i can find out what the largest ID is? 我想做的是找出如何将jsonData中的json脚本转换成一种格式,在其中我可以找出最大的ID是什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.