我正在尝试从mysql中提取数据并在高图条形图上显示,但我不确定我的代码在哪里不正确。结果是一个空白页。
代码可能没有错,因为我从高图提供的index.html文件中获取它,但它由于某种原因不起作用。任何人都可以检查并告诉我在哪里发生错误吗?
<!DOCTYPE HTML><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<?php
$host="localhost";
$username="root";
$password="";
$db="isat";
// Create connection
$con = mysqli_connect($host,$username,$password,$db) or die("Error Message: <br>". mysqli_error($con));
$data=array();
$query= "SELECT standard FROM domainlist";
$result=mysqli_query($con,$query);
while($row=mysqli_fetch_assoc($result)){
$data[]=$row['standard'];
}
?>
<script type="text/javascript">
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
xAxis: {
categories: [<?php echo join($data, ','); ?>]
},
series: [{
data: [],
pointStart: 0,
pointInterval
}]
}); $(function () {
$('#container').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Compliance'
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
}
},
legend: {
reversed: true
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [{
name: 'John',
data: [5, 3, 4, 7, 2]
}, {
name: 'Jane',
data: [2, 2, 3, 2, 1]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}]
});}); </script></head>
<body><div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div></body></html>