title: Generating line graphs with MySQL+PHP+Morris.js
body: <p>I'm using MySQL+PHP+Morris.js to generate some line graphs. I want the result graph to look like this:</p>
  
  <p><a href="http://i.stack.imgur.com/oeD81.png" rel="nofollow">morris.js line graph</a></p>
  
  <p>I understand the data should look like below for morris.js to generate the graph:</p>
  
  <pre><code>{"period": "2014 Q3", "A": 75, "B": 77, "C": 79},
  {"period": "2014 Q2", "A": 85, "B": 87, "C": 89},
  {"period": "2014 Q1", "A": 93, "B": 95, "C": 97}
  </code></pre>
  
  <p>However I'm having trouble getting to this format using PHP+MySQL.</p>
  
  <p>My database structure looks like this.</p>
  
  <pre><code>table1: numbers
  ID  | name | time | number
  ------+------+------+---
  1   | A    | 1    | 75
  2   | A    | 2    | 77
  3   | A    | 3    | 79
  4   | B    | 1    | 85
  5   | B    | 2    | 87
  6   | B    | 3    | 89
  7   | C    | 1    | 93
  8   | C    | 2    | 95
  9   | C    | 3    | 97
  
  
  table2: times
  ID  | time   
  ----+------  
  1   | 2014 Q1
  2   | 2014 Q2
  3   | 2014 Q3
  </code></pre>
  
  <p>Is there a way to get the format <code>morris.js</code> wanted? Or is there any other way to generate the graph using some other kind of format? 
  Hopefully I won't have to change the structure of my database :(</p>
  
  <p>Thanks much!</p>