嗨,我正在尝试从MySql
表中获取数据并Highcharts
通过使用来显示数据,PHP
并且Json
我已经尝试了来自互联网的示例,它运行良好,但是当我尝试从文件中获取数据时却什么也没有显示。
我正在尝试做的事情:我正在创建办公室考勤系统表,并试图每天显示记录。因此,在Y轴我想数名员工和X轴的日期出席。
问题: mu json没有显示任何内容。
这是我的Json
样子:
[["Hamza","07\/04\/2014"],
["Junaid","07\/04\/2014"],
["Usman","07\/04\/2014"],
["Rajab","07\/04\/2014"],
["Hamza","08\/04\/2014"],
["Junaid","08\/04\/2014"],
["Usman","08\/04\/2014"],
["Rajab","08\/04\/2014"]]
我必须重视姓名和日期。
我PHP
正在创建我的Json
代码:
// Set the JSON header
header("Content-type: text/json");
$result = mysqli_query($con,"SELECT * FROM attendence");
$a=array();
while($row = mysqli_fetch_array($result)) {
$row['name'] . "\t" . $row['date']. "\n";
$b=array();
array_push($b,$row['name']);
array_push($b,$row['date']);
array_push($a,$b);
}
echo json_encode($a);
这是我的Jquery代码:
$(function() {
$.getJSON('highchart.php', function(data) {
// Create the chart
$('#chart').highcharts('StockChart', {
rangeSelector : {
selected : 1,
inputEnabled: $('#chart').width() > 480
},
title : {
text : 'Attendence'
},
series : [{
name : 'Empolyees',
data : data,
tooltip: {
valueDecimals: 2
}
}]
});
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句