MySQL到谷歌图表PHP
Posted
技术标签:
【中文标题】MySQL到谷歌图表PHP【英文标题】:MySQL to google charts PHP 【发布时间】:2013-10-14 12:03:08 【问题描述】: <?php
$con=mysql_connect("xxxx.xxxx.xxxx.xx","Myuser","Mypass") or die("Failed to connect with database!!!!");
mysql_select_db("data", $con);
$sth = mysql_query("SELECT * FROM data");
$data = array (
'cols' => array(
array('id' => 'date', 'label' => 'Date ', 'type' => 'datetime'),
array('id' => 'temp1', 'label' => 'Temp 1', 'type' => 'number'),
array('id' => 'temp2', 'label' => 'Temp 2', 'type' => 'number')
),
'rows' => array()
);
while ($res = mysql_fetch_assoc($sth))
// array nesting is complex owing to to google charts api
array_push($data['rows'], array('c' => array(
array('v' => $res['date']),
array('v' => $res['temp1']),
array('v' => $res['temp2'])
)));
?>
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", packages:["corechart"]);
google.setOnLoadCallback(drawChart);
function drawChart()
var bar_chart_data = new google.visualization.DataTable(<?php echo json_encode($data); ?>);
var options =
title: 'Weather data'
;
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(bar_chart_data, options);
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
我在完成此操作时遇到问题,echo count($bar_chart_rows_arr) AND echo count($task_submissions_arr) 显示出相应的良好结果(表中的行数)。图表框架正在显示,但没有表格/图表数据。有什么建议吗?
输出html:
6060
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", packages:["corechart"]);
google.setOnLoadCallback(drawChart);
function drawChart()
var bar_chart_data = new google.visualization.DataTable(
cols: ["id":"date","label":"Date ","type":"datetime","id":"temp1","label":"Temp 1","type":"number","id":"temp2","label":"Temp 2","type":"number"],
rows: ["c":["date":"id":"1","temp1":"10.75","temp2":"4","date":"2013-10-05 20:41:00","temp1":"id":"1","temp1":"10.75","temp2":"4","date":"2013-10-05 20:41:00","temp2":"id":"1","temp1":"10.75","temp2":"4","date":"2013-10-05 20:41:00"],"c":["date":"id":"2","temp1":"9.125","temp2":"4","date":"2013-10-05 22:18:17","temp1":"id":"2","temp1":"9.125","temp2":"4","date":"2013-10-05 22:18:17","temp2":"id":"2","temp1":"9.125","temp2":"4","date":"2013-10-05 22:18:17"],"c":["date":"id":"3","temp1":"8.187","temp2":"4","date":"2013-10-05 23:51:20","temp1":"id":"3","temp1":"8.187","temp2":"4","date":"2013-10-05 23:51:20","temp2":"id":"3","temp1":"8.187","temp2":"4","date":"2013-10-05 23:51:20"],"c":["date":"id":"4","temp1":"17.187","temp2":"4","date":"2013-10-07 11:39:21","temp1":"id":"4","temp1":"17.187","temp2":"4","date":"2013-10-07 11:39:21","temp2":"id":"4","temp1":"17.187","temp2":"4","date":"2013-10-07 11:39:21"],"c":["date":"id":"5","temp1":"17.062","temp2":"4","date":"2013-10-07 12:00:05","temp1":"id":"5","temp1":"17.062","temp2":"4","date":"2013-10-07 12:00:05","temp2":"id":"5","temp1":"17.062","temp2":"4","date":"2013-10-07 12:00:05"],"c":["date":"id":"6","temp1":"17.187","temp2":"4","date":"2013-10-07 14:30:04","temp1":"id":"6","temp1":"17.187","temp2":"4","date":"2013-10-07 14:30:04","temp2":"id":"6","temp1":"17.187","temp2":"4","date":"2013-10-07 14:30:04"],"c":["date":"id":"7","temp1":"17.25","temp2":"4","date":"2013-10-07 15:00:04","temp1":"id":"7","temp1":"17.25","temp2":"4","date":"2013-10-07 15:00:04","temp2":"id":"7","temp1":"17.25","temp2":"4","date":"2013-10-07 15:00:04"],"c":["date":"id":"8","temp1":"17.562","temp2":"4","date":"2013-10-07 15:30:04","temp1":"id":"8","temp1":"17.562","temp2":"4","date":"2013-10-07 15:30:04","temp2":"id":"8","temp1":"17.562","temp2":"4","date":"2013-10-07 15:30:04"],"c":["date":"id":"9","temp1":"17.875","temp2":"4","date":"2013-10-07 16:00:04","temp1":"id":"9","temp1":"17.875","temp2":"4","date":"2013-10-07 16:00:04","temp2":"id":"9","temp1":"17.875","temp2":"4","date":"2013-10-07 16:00:04"],"c":["date":"id":"10","temp1":"17.875","temp2":"4","date":"2013-10-07 16:30:04","temp1":"id":"10","temp1":"17.875","temp2":"4","date":"2013-10-07 16:30:04","temp2":"id":"10","temp1":"17.875","temp2":"4","date":"2013-10-07 16:30:04"],"c":["date":"id":"11","temp1":"17.375","temp2":"4","date":"2013-10-07 17:00:04","temp1":"id":"11","temp1":"17.375","temp2":"4","date":"2013-10-07 17:00:04","temp2":"id":"11","temp1":"17.375","temp2":"4","date":"2013-10-07 17:00:04"],"c":["date":"id":"12","temp1":"17.062","temp2":"4","date":"2013-10-07 17:30:04","temp1":"id":"12","temp1":"17.062","temp2":"4","date":"2013-10-07 17:30:04","temp2":"id":"12","temp1":"17.062","temp2":"4","date":"2013-10-07 17:30:04"],"c":["date":"id":"13","temp1":"17.062","temp2":"4","date":"2013-10-07 18:00:04","temp1":"id":"13","temp1":"17.062","temp2":"4","date":"2013-10-07 18:00:04","temp2":"id":"13","temp1":"17.062","temp2":"4","date":"2013-10-07 18:00:04"],"c":["date":"id":"14","temp1":"16.187","temp2":"4","date":"2013-10-07 18:30:04","temp1":"id":"14","temp1":"16.187","temp2":"4","date":"2013-10-07 18:30:04","temp2":"id":"14","temp1":"16.187","temp2":"4","date":"2013-10-07 18:30:04"],"c":["date":"id":"15","temp1":"15.875","temp2":"4","date":"2013-10-07 19:00:03","temp1":"id":"15","temp1":"15.875","temp2":"4","date":"2013-10-07 19:00:03","temp2":"id":"15","temp1":"15.875","temp2":"4","date":"2013-10-07 19:00:03"],"c":["date":"id":"16","temp1":"15.625","temp2":"4","date":"2013-10-07 19:30:03","temp1":"id":"16","temp1":"15.625","temp2":"4","date":"2013-10-07 19:30:03","temp2":"id":"16","temp1":"15.625","temp2":"4","date":"2013-10-07 19:30:03"],"c":["date":"id":"17","temp1":"15.437","temp2":"4","date":"2013-10-07 20:00:05","temp1":"id":"17","temp1":"15.437","temp2":"4","date":"2013-10-07 20:00:05","temp2":"id":"17","temp1":"15.437","temp2":"4","date":"2013-10-07 20:00:05"],"c":["date":"id":"18","temp1":"15.375","temp2":"4","date":"2013-10-07 20:30:03","temp1":"id":"18","temp1":"15.375","temp2":"4","date":"2013-10-07 20:30:03","temp2":"id":"18","temp1":"15.375","temp2":"4","date":"2013-10-07 20:30:03"],"c":["date":"id":"19","temp1":"15.312","temp2":"4","date":"2013-10-07 21:00:04","temp1":"id":"19","temp1":"15.312","temp2":"4","date":"2013-10-07 21:00:04","temp2":"id":"19","temp1":"15.312","temp2":"4","date":"2013-10-07 21:00:04"],"c":["date":"id":"20","temp1":"15.312","temp2":"4","date":"2013-10-07 21:30:04","temp1":"id":"20","temp1":"15.312","temp2":"4","date":"2013-10-07 21:30:04","temp2":"id":"20","temp1":"15.312","temp2":"4","date":"2013-10-07 21:30:04"],"c":["date":"id":"21","temp1":"15.312","temp2":"4","date":"2013-10-07 22:00:04","temp1":"id":"21","temp1":"15.312","temp2":"4","date":"2013-10-07 22:00:04","temp2":"id":"21","temp1":"15.312","temp2":"4","date":"2013-10-07 22:00:04"],"c":["date":"id":"22","temp1":"15.25","temp2":"15.25","date":"2013-10-07 22:20:00","temp1":"id":"22","temp1":"15.25","temp2":"15.25","date":"2013-10-07 22:20:00","temp2":"id":"22","temp1":"15.25","temp2":"15.25","date":"2013-10-07 22:20:00"],"c":["date":"id":"23","temp1":"15.312","temp2":"15.25","date":"2013-10-07 22:21:40","temp1":"id":"23","temp1":"15.312","temp2":"15.25","date":"2013-10-07 22:21:40","temp2":"id":"23","temp1":"15.312","temp2":"15.25","date":"2013-10-07 22:21:40"],"c":["date":"id":"24","temp1":"15.25","temp2":"15.187","date":"2013-10-07 22:22:25","temp1":"id":"24","temp1":"15.25","temp2":"15.187","date":"2013-10-07 22:22:25","temp2":"id":"24","temp1":"15.25","temp2":"15.187","date":"2013-10-07 22:22:25"],"c":["date":"id":"25","temp1":"15.312","temp2":"15.25","date":"2013-10-07 22:30:06","temp1":"id":"25","temp1":"15.312","temp2":"15.25","date":"2013-10-07 22:30:06","temp2":"id":"25","temp1":"15.312","temp2":"15.25","date":"2013-10-07 22:30:06"],"c":["date":"id":"26","temp1":"15.312","temp2":"15.312","date":"2013-10-07 22:53:33","temp1":"id":"26","temp1":"15.312","temp2":"15.312","date":"2013-10-07 22:53:33","temp2":"id":"26","temp1":"15.312","temp2":"15.312","date":"2013-10-07 22:53:33"],"c":["date":"id":"27","temp1":"15.312","temp2":"15.25","date":"2013-10-07 22:53:45","temp1":"id":"27","temp1":"15.312","temp2":"15.25","date":"2013-10-07 22:53:45","temp2":"id":"27","temp1":"15.312","temp2":"15.25","date":"2013-10-07 22:53:45"],"c":["date":"id":"28","temp1":"15.375","temp2":"15.312","date":"2013-10-07 23:00:05","temp1":"id":"28","temp1":"15.375","temp2":"15.312","date":"2013-10-07 23:00:05","temp2":"id":"28","temp1":"15.375","temp2":"15.312","date":"2013-10-07 23:00:05"],"c":["date":"id":"29","temp1":"14.937","temp2":"15.25","date":"2013-10-07 23:01:04","temp1":"id":"29","temp1":"14.937","temp2":"15.25","date":"2013-10-07 23:01:04","temp2":"id":"29","temp1":"14.937","temp2":"15.25","date":"2013-10-07 23:01:04"],"c":["date":"id":"30","temp1":"14.937","temp2":"15.25","date":"2013-10-07 23:01:11","temp1":"id":"30","temp1":"14.937","temp2":"15.25","date":"2013-10-07 23:01:11","temp2":"id":"30","temp1":"14.937","temp2":"15.25","date":"2013-10-07 23:01:11"],"c":["date":"id":"31","temp1":"14.875","temp2":"15.312","date":"2013-10-07 23:01:16","temp1":"id":"31","temp1":"14.875","temp2":"15.312","date":"2013-10-07 23:01:16","temp2":"id":"31","temp1":"14.875","temp2":"15.312","date":"2013-10-07 23:01:16"],"c":["date":"id":"32","temp1":"14.812","temp2":"15.312","date":"2013-10-07 23:01:21","temp1":"id":"32","temp1":"14.812","temp2":"15.312","date":"2013-10-07 23:01:21","temp2":"id":"32","temp1":"14.812","temp2":"15.312","date":"2013-10-07 23:01:21"],"c":["date":"id":"33","temp1":"14.75","temp2":"15.25","date":"2013-10-07 23:01:38","temp1":"id":"33","temp1":"14.75","temp2":"15.25","date":"2013-10-07 23:01:38","temp2":"id":"33","temp1":"14.75","temp2":"15.25","date":"2013-10-07 23:01:38"],"c":["date":"id":"34","temp1":"14.75","temp2":"15.25","date":"2013-10-07 23:03:29","temp1":"id":"34","temp1":"14.75","temp2":"15.25","date":"2013-10-07 23:03:29","temp2":"id":"34","temp1":"14.75","temp2":"15.25","date":"2013-10-07 23:03:29"],"c":["date":"id":"35","temp1":"14.375","temp2":"15.25","date":"2013-10-07 23:03:37","temp1":"id":"35","temp1":"14.375","temp2":"15.25","date":"2013-10-07 23:03:37","temp2":"id":"35","temp1":"14.375","temp2":"15.25","date":"2013-10-07 23:03:37"],"c":["date":"id":"36","temp1":"14.375","temp2":"15.312","date":"2013-10-07 23:04:15","temp1":"id":"36","temp1":"14.375","temp2":"15.312","date":"2013-10-07 23:04:15","temp2":"id":"36","temp1":"14.375","temp2":"15.312","date":"2013-10-07 23:04:15"],"c":["date":"id":"37","temp1":"14.25","temp2":"15.25","date":"2013-10-07 23:09:53","temp1":"id":"37","temp1":"14.25","temp2":"15.25","date":"2013-10-07 23:09:53","temp2":"id":"37","temp1":"14.25","temp2":"15.25","date":"2013-10-07 23:09:53"],"c":["date":"id":"38","temp1":"14.187","temp2":"15.187","date":"2013-10-07 23:19:44","temp1":"id":"38","temp1":"14.187","temp2":"15.187","date":"2013-10-07 23:19:44","temp2":"id":"38","temp1":"14.187","temp2":"15.187","date":"2013-10-07 23:19:44"],"c":["date":"id":"39","temp1":"14.125","temp2":"15.125","date":"2013-10-07 23:30:05","temp1":"id":"39","temp1":"14.125","temp2":"15.125","date":"2013-10-07 23:30:05","temp2":"id":"39","temp1":"14.125","temp2":"15.125","date":"2013-10-07 23:30:05"],"c":["date":"id":"40","temp1":"14.125","temp2":"15","date":"2013-10-08 00:00:06","temp1":"id":"40","temp1":"14.125","temp2":"15","date":"2013-10-08 00:00:06","temp2":"id":"40","temp1":"14.125","temp2":"15","date":"2013-10-08 00:00:06"],"c":["date":"id":"41","temp1":"13.875","temp2":"14.937","date":"2013-10-08 00:30:05","temp1":"id":"41","temp1":"13.875","temp2":"14.937","date":"2013-10-08 00:30:05","temp2":"id":"41","temp1":"13.875","temp2":"14.937","date":"2013-10-08 00:30:05"],"c":["date":"id":"42","temp1":"13.75","temp2":"14.937","date":"2013-10-08 01:00:05","temp1":"id":"42","temp1":"13.75","temp2":"14.937","date":"2013-10-08 01:00:05","temp2":"id":"42","temp1":"13.75","temp2":"14.937","date":"2013-10-08 01:00:05"],"c":["date":"id":"43","temp1":"13.812","temp2":"14.75","date":"2013-10-08 01:30:06","temp1":"id":"43","temp1":"13.812","temp2":"14.75","date":"2013-10-08 01:30:06","temp2":"id":"43","temp1":"13.812","temp2":"14.75","date":"2013-10-08 01:30:06"],"c":["date":"id":"44","temp1":"13.937","temp2":"14.625","date":"2013-10-08 02:00:06","temp1":"id":"44","temp1":"13.937","temp2":"14.625","date":"2013-10-08 02:00:06","temp2":"id":"44","temp1":"13.937","temp2":"14.625","date":"2013-10-08 02:00:06"],"c":["date":"id":"45","temp1":"14","temp2":"14.625","date":"2013-10-08 02:30:05","temp1":"id":"45","temp1":"14","temp2":"14.625","date":"2013-10-08 02:30:05","temp2":"id":"45","temp1":"14","temp2":"14.625","date":"2013-10-08 02:30:05"],"c":["date":"id":"46","temp1":"14.062","temp2":"14.812","date":"2013-10-08 03:00:06","temp1":"id":"46","temp1":"14.062","temp2":"14.812","date":"2013-10-08 03:00:06","temp2":"id":"46","temp1":"14.062","temp2":"14.812","date":"2013-10-08 03:00:06"],"c":["date":"id":"47","temp1":"14.062","temp2":"14.937","date":"2013-10-08 03:30:05","temp1":"id":"47","temp1":"14.062","temp2":"14.937","date":"2013-10-08 03:30:05","temp2":"id":"47","temp1":"14.062","temp2":"14.937","date":"2013-10-08 03:30:05"],"c":["date":"id":"48","temp1":"13.937","temp2":"14.875","date":"2013-10-08 04:00:06","temp1":"id":"48","temp1":"13.937","temp2":"14.875","date":"2013-10-08 04:00:06","temp2":"id":"48","temp1":"13.937","temp2":"14.875","date":"2013-10-08 04:00:06"],"c":["date":"id":"49","temp1":"14","temp2":"14.812","date":"2013-10-08 04:30:05","temp1":"id":"49","temp1":"14","temp2":"14.812","date":"2013-10-08 04:30:05","temp2":"id":"49","temp1":"14","temp2":"14.812","date":"2013-10-08 04:30:05"],"c":["date":"id":"50","temp1":"13.625","temp2":"14.75","date":"2013-10-08 05:00:06","temp1":"id":"50","temp1":"13.625","temp2":"14.75","date":"2013-10-08 05:00:06","temp2":"id":"50","temp1":"13.625","temp2":"14.75","date":"2013-10-08 05:00:06"],"c":["date":"id":"51","temp1":"13.375","temp2":"14.687","date":"2013-10-08 03:30:06","temp1":"id":"51","temp1":"13.375","temp2":"14.687","date":"2013-10-08 03:30:06","temp2":"id":"51","temp1":"13.375","temp2":"14.687","date":"2013-10-08 03:30:06"],"c":["date":"id":"52","temp1":"13.562","temp2":"14.562","date":"2013-10-08 04:00:06","temp1":"id":"52","temp1":"13.562","temp2":"14.562","date":"2013-10-08 04:00:06","temp2":"id":"52","temp1":"13.562","temp2":"14.562","date":"2013-10-08 04:00:06"],"c":["date":"id":"53","temp1":"13.687","temp2":"14.312","date":"2013-10-08 04:30:05","temp1":"id":"53","temp1":"13.687","temp2":"14.312","date":"2013-10-08 04:30:05","temp2":"id":"53","temp1":"13.687","temp2":"14.312","date":"2013-10-08 04:30:05"],"c":["date":"id":"54","temp1":"14","temp2":"14.375","date":"2013-10-08 05:00:05","temp1":"id":"54","temp1":"14","temp2":"14.375","date":"2013-10-08 05:00:05","temp2":"id":"54","temp1":"14","temp2":"14.375","date":"2013-10-08 05:00:05"],"c":["date":"id":"55","temp1":"13.875","temp2":"14.5","date":"2013-10-08 05:30:05","temp1":"id":"55","temp1":"13.875","temp2":"14.5","date":"2013-10-08 05:30:05","temp2":"id":"55","temp1":"13.875","temp2":"14.5","date":"2013-10-08 05:30:05"],"c":["date":"id":"56","temp1":"13.75","temp2":"14.5","date":"2013-10-08 06:00:06","temp1":"id":"56","temp1":"13.75","temp2":"14.5","date":"2013-10-08 06:00:06","temp2":"id":"56","temp1":"13.75","temp2":"14.5","date":"2013-10-08 06:00:06"],"c":["date":"id":"57","temp1":"13.812","temp2":"14.5","date":"2013-10-08 06:30:05","temp1":"id":"57","temp1":"13.812","temp2":"14.5","date":"2013-10-08 06:30:05","temp2":"id":"57","temp1":"13.812","temp2":"14.5","date":"2013-10-08 06:30:05"],"c":["date":"id":"58","temp1":"14.125","temp2":"14.562","date":"2013-10-08 07:00:05","temp1":"id":"58","temp1":"14.125","temp2":"14.562","date":"2013-10-08 07:00:05","temp2":"id":"58","temp1":"14.125","temp2":"14.562","date":"2013-10-08 07:00:05"],"c":["date":"id":"59","temp1":"14.937","temp2":"14.625","date":"2013-10-08 07:30:05","temp1":"id":"59","temp1":"14.937","temp2":"14.625","date":"2013-10-08 07:30:05","temp2":"id":"59","temp1":"14.937","temp2":"14.625","date":"2013-10-08 07:30:05"],"c":["date":"id":"60","temp1":"15.812","temp2":"15.937","date":"2013-10-08 14:34:40","temp1":"id":"60","temp1":"15.812","temp2":"15.937","date":"2013-10-08 14:34:40","temp2":"id":"60","temp1":"15.812","temp2":"15.937","date":"2013-10-08 14:34:40"]] );
var options =
title: 'Weather data'
;
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(bar_chart_data, options);
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
【问题讨论】:
$bar_chart_cols_arr
和 $bar_chart_rows_arr
的 JSON 输出是什么 - 它们是否与 Google Line Chart 的预期正确对应? Google Line Chart Docs
你能发布 javascript 而不是神秘的 PHP 数组吗?
我们需要查看 json 编码数组的内容是什么,但我怀疑您的问题是您直接从数据库中输出日期而没有将它们转换为适当的格式。
更新了,temp1 & temp2 是 mysql 表中的 FLOAT,日期是时间戳。如果有任何遗漏,我会附上更多信息?
查看您的行的 json 输出 - 全部为“空”,因此为什么没有绘制图表。删除$task_submissions_arr[][] = $res;
中多余的[]
。
【参考方案1】:
根据您最初发布的代码 - 更改
$task_submissions_arr[][] = $res;
到
$task_submissions_arr[] = $res;
【讨论】:
请阅读 cmets,这个答案已经被提出,它不是解决方案。 你会注意到我是“根据你最初发布的代码”写的——即this code。无论如何,@asgallant 的答案也很有效。【参考方案2】:您的 PHP 代码为 Google Visualization API 生成格式不正确的 JSON。试试这个:
<?php
$con=mysql_connect("xxxx.xxxx.xxxx.xx","Myuser","Mypass") or die("Failed to connect with database!!!!");
mysql_select_db("data", $con);
$sth = mysql_query("SELECT * FROM data");
$data = array (
'cols' => array(
array('id' => 'date', 'label' => 'Date ', 'type' => 'datetime'),
array('id' => 'temp1', 'label' => 'Temp 1', 'type' => 'number'),
array('id' => 'temp2', 'label' => 'Temp 2', 'type' => 'number')
),
'rows' => array()
);
while ($res = mysql_fetch_assoc($sth))
// array nesting is complex owing to to google charts api
array_push($data['rows'], array('c' => array(
array('v' => $res['date']),
array('v' => $res['temp1']),
array('v' => $res['temp2'])
)));
?>
然后在你的javascript中:
var bar_chart_data = new google.visualization.DataTable(<?php echo json_encode($data); ?>);
【讨论】:
Okei,用你的代码更新了文本^,现在连图表框都没有显示,我做错了什么? 你能更新输出的 HTML 以便我看看可能是什么原因吗? 可能是这一行:'cols' ==> array(
- ==>
应该是 =>
我注意到我遗漏的另一件事:var bar_chart_data = new google.visualization.DataTable(<?php echo json_encode($data); ?>);
行中的 echo
。如果 PHP 代码正确,这将阻止图表接收任何数据。如果这不能解决问题,您将需要对 PHP 进行一些调试以找出它在哪里引发错误(您的服务器日志可能包含一些提示,但众所周知,PHP 在引发远触发的模糊错误方面很糟糕来自代码中实际问题的站点)。【参考方案3】:
感谢您在设计中的所有帮助,我有几个错误,但关键错误是我使用 MySQL 数据库中的 date, datetime 格式错误,当我从 date / datetime 更改它时到 string 代码就完成了!
$table['cols']=array(
array('label' => 'Date', type=>'string'),
array('label' => 'Temp 1', type=>'number'),
array('label' =>'Temp 2', type=>'number'),
);
杰森结果:
new google.visualization.DataTable("cols":["label":"Date","type":"string","label":"Temp 1","type":"number","label":"Temp 2","type":"number"],"rows":["c":["v":"2013-10-05 20:41:00","v":10.75,"v":4]
【讨论】:
以上是关于MySQL到谷歌图表PHP的主要内容,如果未能解决你的问题,请参考以下文章