How to get mysql data into a google chart using php loop?

后端 未结 1 1854
长情又很酷
长情又很酷 2020-12-20 07:15

I\'ve created a Google chart and I\'ve added data taken from the database itself. When getting data through php loops though, I have had some difficulty because I couldn\'t

1条回答
  •  余生分开走
    2020-12-20 07:40

    Try to tackle one problem after the other. First, get the data you need from the database. Then, create the data structure you need in PHP, and convert it to JavaScript using json_encode(). Finally, pass it to the visualization function in JavaScript:

    
    var raw_data = ;
    
    // visualize
    var data = google.visualization.arrayToDataTable(raw_data);
    

    0 讨论(0)
提交回复
热议问题