title: dynamic spline highchart from database
body: <p>I try to make a spline highchart and implement solution from <a href="https://stackoverflow.com/questions/9941188/how-to-load-data-from-json-to-highchart">How to load data from JSON to Highchart?</a>, that's an answer from Mina Gabriel. The codes look like this.</p>
  
  <p>In <code>test.php</code></p>
  
  <pre><code>}
  // Set the JSON header
  header("Content-type: text/json");
  
  // The x value is the current JavaScript time, which is the Unix time multiplied     by       1000.
  $x = time() * 1000;
  $y = rand(0,100) ; 
  
  
  
  // Create a PHP array and echo it as JSON
  $ret = array($x, $y);
  echo json_encode($ret);
  ?&gt;
  </code></pre>
  
  <p>And in the highchart script:</p>
  
  <pre><code>&lt;script&gt;
  /**
   * Request data from the server, add it to the graph and set a timeout to request again
   */
  var chart; // global
  function requestData() {
  $.ajax({
      url: 'http://localhost:8080/test.php',
      success: function(point) {
          var series = chart.series[0],
              shift = series.data.length &gt; 20; // shift if the series is longer than 20
  
          // add the point
          chart.series[0].addPoint(point, true, shift);
  
          // call it again after one second
          setTimeout(requestData, 1000);    
      },
      cache: false
     });
   }
   $(document).ready(function() {
     chart = new Highcharts.Chart({
        chart: {
          renderTo: 'container',
          defaultSeriesType: 'spline',
          events: {
              load: requestData
          }
      },
      title: {
          text: 'Live random data'
      },
      xAxis: {
          type: 'datetime',
          tickPixelInterval: 100,
          maxZoom: 20 * 1000
      },
  
      yAxis: {
          minPadding: 0.2,
          maxPadding: 0.2,
          title: {
              text: 'Value',
              margin: 80
          }
      },
      series: [{
          name: 'Random data',
          data: []
       }]
     });        
  });
    &lt;/script&gt;
    &lt;  /head&gt;
  &lt;body&gt;
  </code></pre>
  
  <p>And those just work well. But when I try to change the code in the <code>test.php</code> to set the y-value as a number from database like this:</p>
  
  <pre><code>&lt;?php
  header("Content-type: text/json");
  $db = mysql_connect("localhost","myusername","mypassword");
  mysql_select_db("mydatabase");
  
  
  $day=date('Y-m-d'); //UTC standar time
  
  $result = mysql_query("SELECT COUNT(*) FROM table WHERE time='{$day}';");
  $count = mysql_fetch_array($result);
  
  // The x value is the current JavaScript time, which is the Unix time multiplied by       1000.
  $x = time() * 1000;
  $y = $count[0]; 
  
  // Create a PHP array and echo it as JSON
  $ret = array($x, $y);
  echo json_encode($ret);
  ?&gt;
  </code></pre>
  
  <p>the line chart doesnt work. I've checked the sql code and it just works right. Did I miss something?</p>