title: Graphs from MYSQL to jquery FLOT
body: <p>I've discovered flot for jquery for drawing nice graphs. But I can't parse the data I want to represent from MYSQL. It's driving me crazy because I get this error:</p>
  
  <pre><code>uncaught exception: Invalid dimensions for plot, width = 0, height = 0
  </code></pre>
  
  <p>Is there any way to put MYSQL data into flot apart from this?:</p>
  
  <p>php part:</p>
  
  <pre><code>&lt;?php 
  include './includes/config.php';
  include './includes/opendb.php';
  
  $ID=$_GET["ID"];
  $data=$_GET["data"];
  
  $query_set = "SET @cnt = -1";
  $query = "SELECT @cnt +1, {$data} FROM table_inf where ID = {$ID};";
  
  $result = mysql_query("{$query_set}");
  if (!$result) {
  die("Query to show fields from table failed");
  }
  
  $result = mysql_query("{$query_select}");
  if (!$result) {
  die("Query to show fields from table failed");
  }
  
  $arr = array();
  while($obj = mysql_fetch_object($result))
  {
      $arr[] = $obj;
  }
  
  //NOW OUTPUT THE DATA:
  print json_encode($arr);
  
  mysql_free_result($result);
  include './includes/closedb.php';
  ?&gt;
  </code></pre>
  
  <p>javascript part:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  function get_data() {
  
  var options = {
  lines: {show: true},
  points: {show: true},
  yaxis: { min: 0 },
  };
  
  $.ajax({ url: "return_values.php?ID=1&amp;data=MAG",
  dataType: "json",
  success: function(result)
  {
  plot = $.plot($("#placeholder"), result, options);
  }
  });
  };
  &lt;/script&gt;
  </code></pre>
  
  <p>I've been googling.. with no success. Seems pretty simple but plot simply won't understand the data... or something...</p>
  
  <p>The output of the php file is as follows (for two entries for example):</p>
  
  <pre><code>[{"@cnt := @cnt + 1":"0","MAG":"6.87"},{"@cnt := @cnt + 1":"1","MAG":"11.44"}]
  </code></pre>
  
  <p>where @cnt is a counter for the x axis incrementing of each row (0,1,2,3...) and MAG is the data itself to show on the y axis.</p>
  
  <p>The jquery i'm using is:</p>
  
  <pre><code>&lt;script src="./javascripting/jquery-1.3.2.js" type="text/javascript"&gt;&lt;/script&gt;   
  &lt;script src="./javascripting/jquery.tabs.pack.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script language="javascript" type="text/javascript" src="./javascripting/jquery.flot.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>where flot is version 0.5 and the browser firefox.</p>