简体   繁体   中英

Google Pie Chart with getting data from mysql

I'm trying to make google pie chart from data from mysql but can't figure out how. What I want to show in charts is saved id database like:

Ads Table:
ad_id location price sourceId(FG)
1     London   500      3
2     Moscow   2000     4
3     London   600      3
4     Berlin   400      4

What I want to make is get sourceId by how many times there is source with id 3, how many times there is source with id 4, etc... and build chart on this data. Also can't figure where to save this data so it's readable by js from google charts.

It sounds like a frequency distribution.. But with all the other information I am not sure if this is what you are looking for.

SQL:

SELECT COUNT(ad_id),`sourceId(FG)` FROM Ads GROUP BY `sourceId(FG)`;

Then you should have your frequency distribution.

For plotting the data, the most straight forward way is to use the PHP output as the value pairs for the Google Chart, when you setup the chart. The variation on how you can do this is endless..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM