title: How can I create a Flot graph with values from database, using JavaScript?
body: <p>I want to create a Flot graph that have on x-axis date values. I don't want to write manually the date values so I stored them in database like TIMESTAMP values.
  The connection to database is like: </p>
  
  <pre><code>&lt;?php
    $pdo = new PDO('mysql:host=example.com; dbname=database', 'user', 'password')
  ?&gt;
  </code></pre>
  
  <p>The javascript code looks like: </p>
  
  <pre><code>        var graphData = [ {
          // first graphic
          data: [ [(new Date("2006-06-12 19:13:37")).getTime(), 600], [(new Date("2006-06-21 19:13:37")).getTime(), 550], [(new Date("2006-07-1 19:13:37")).getTime(), 600]],
          color: '#77b7c5',
          points: { radius: 4, fillColor: '#77b7c5' }
      }, {
          //the second graphic
          data: [[(new Date("2006-06-11 19:13:37")).getTime(), 3210.196] , [(new Date("2006-07-3 19:13:37")).getTime(), 3310.196], [(new Date("2006-07-23 19:13:37")).getTime(),3875.422]],
          color: 'red'
      }       
  ];
  </code></pre>
  
  <p>I want to get those date values directly from my database and to create the graphic I use JavaScript. I know that is more secure to work with database in php and I don't know how I can display the flot graphic using values from database. Any ideas?</p>