I am using ZingChart . At loading of the page the chart successfully loads the data from MySql database . But after some interval when the database is updated how to load the latest data ? Please help me out . I have tried the following code in my index.php page to do this but it does not work.
<script>
var myData=[
<?php
$conn =mysql_connect("localhost","root","") or die ("we couldn't connect!");
mysql_select_db("webauth");
$rs = mysql_query("SELECT * FROM test") or die(mysql_error());
while($row = mysql_fetch_array($rs))
{
echo $row['label'].',';
}?>];
var myLabels=[<?php
$conn =mysql_connect("localhost","root","") or die ("we couldn't connect!");
mysql_select_db("webauth");
$rs = mysql_query("SELECT * FROM test") or die(mysql_error());
while($row2 = mysql_fetch_array($rs))
{
echo '"'.$row2['value'].'"'.',';
}?>];
window.onload=function(){
window.alert(myData);
zingchart.render({
id:'chartDiv',
data:{
"type":"bar",
"scale-x":{
"values":myLabels,
},
"series":[
{
"values":myData
}
]
,
"refresh":{
"type":"feed",
"transport":"http",
"url":"feed.php?",
"interval":200
},
}
});
}
</script>
and using this code in feed.php page
<script>
var myData=[
<?php
?>
[
{
$conn =mysql_connect("localhost","root","") or die ("we couldn't connect!");
mysql_select_db("webauth");
$rs = mysql_query("SELECT * FROM test") or die(mysql_error());
while($row = mysql_fetch_array($rs))
{
"plot<?php echo $row['label'].',';
}?>"];
}
]
var myLabels=[<?php
?>
[
{
$conn =mysql_connect("localhost","root","") or die ("we couldn't connect!");
mysql_select_db("webauth");
$rs = mysql_query("SELECT * FROM test") or die(mysql_error());
while($row2 = mysql_fetch_array($rs))
{
"plot<?php echo '"'.$row2['value'].'"'.',';
}?>"];
}
]
</script>