how to better store data in the database [‘2004’, 1000, 400],

How can I keep values ​​in the database, then simply via for or foreach to output values ​​in this form: there is a bank table and allow the charts field what it is type, and how to store …

data.addRows([
      ['2004', 1000, 400],
      ['2005', 1170, 460],
      ['2006',  860, 580],
      ['2007', 1030, 540]
    ]);
function drawChart() {
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Year');
    data.addColumn('number', 'Sales');
    data.addColumn('number', 'Expenses');
    data.addRows([
      ['2004', 1000, 400],
      ['2005', 1170, 460],
      ['2006',  860, 580],
      ['2007', 1030, 540]
    ]);
    var options = {
      width: 400, height: 240,
      title: 'Company Performance'
    };
    var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
    chart.draw(data, options);
  }

Answer 1, Authority 100%

um … well, throw everything in int’y. And then you generate the JS code using PHP:

var dataRows = [
      <?/* */?>
    ];
data.addRows(dataRows);
function drawChart() {
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Year');
    data.addColumn('number', 'Sales');
    data.addColumn('number', 'Expenses');
    data.addRows(dataRows);
    ...