0
我正在从MySQL的图表工作,我想要现场或每10秒更新一次。Php live google图表
我的数据库是关于天气和通过arduino天气盾收集数据.... 我可以显示图表,当我点击该页面,但我想更新记录在数据库中的数据每5秒钟是我的代码,希望有人能帮助:
<?php
function tempf($input,$name){
global $conn;
echo ' <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 data = google.visualization.arrayToDataTable([
["Year", "'.$name.'"],';
$resultValue = mysqli_query($conn, "SELECT * FROM daily ORDER BY timeStamp DESC LIMIT 200 ");
if(mysqli_num_rows($resultValue)>0){
while($rowValue = mysqli_fetch_array($resultValue)){
echo '["'.$rowValue['timeStamp'].'", '.$rowValue[''.$input.''].'],';
}
}
echo ']);
var options = {
title: "Graph"
};
var chart = new google.visualization.LineChart(document.getElementById("chart_div"));
chart.draw(data, options);
}
</script>
<div id="chart_div" style="width: 900px; height: 500px; margin-left:4.5cm; "></div>';
}
?>
我用这个页面来获得每列图表在我的MySQL数据库 感谢
使用JavaScript来刷新页面每隔5秒 – kimbarcelona 2014-09-23 23:27:14
@kimbarcelona 那么我可以这样做,但我有一个现场背景和图表使用延迟显示,所以我不能使用它 – 2014-09-23 23:31:31