title: Real time graphing with flot, mysql, php
body: <p>I'm trying to draw a real time graph as my mysql table is constantly being inserted with values, like a moving graph referenced from 
  <a href="http://kalanir.blogspot.com/2009/11/how-to-plot-moving-graphs-using-flot.html" rel="nofollow noreferrer">http://kalanir.blogspot.com/2009/11/how-to-plot-moving-graphs-using-flot.html</a>
  The values actually come from a carbon dioxide sensor which updates the value of the table with <em>co2</em> values with positions <em>id</em>. I changed her Math.Random to the code below:</p>
  
  <pre><code>&lt;?php $result = mysql_query("SELECT * FROM node1 ORDER BY id DESC LIMIT 1")or die(mysql_error());?&gt;
  &lt;?php $row = mysql_fetch_array( $result );?&gt;
  
  var j = "&lt;?php echo $row['co2'];?&gt;";
  var next = "&lt;?php echo $row['id'];?&gt;";
  
  for (var i = 0; i &lt; this.xscale - 1; i++) 
  {  
    this.array[i] = [i,this.array[i+1][1]];  // (x,y)  
  }   
  this.array[this.xscale - 1] = [this.xscale - 1,j]; 
  </code></pre>
  
  <p>However, when i run this code, the first value changes, after which it remains constant, even though the last row of the table is being updated.
  I heard it is because in php, the server is only polled once. Therefore i only get a constant reading of the first data. Is there any way in which i can make the graph update to the last value of the table? with ajax?</p>
  
  <p>Thanks for your help</p>