Skip to content
Advertisement

Google charts from MySQL

I have tried for several hours to get MySQL data in a Google charts but I can’t wrap my head around how to make a working page from the examples I’ve come across on the internet.

To start fresh I took a example from Google charts and manually filled it with data. This gives me the graph I want to have. the Google charts graph is generated by a simple HTML PAGE (JUST THE VARIABLE PART:

JavaScript

I made the same data output in MySQL:

JavaScript

which results in same data: http://i60.tinypic.com/6nqp76.png

But I can’t get the data loaded as shown in this example: http://datamakessense.com/google-charts-api-from-your-sql-database-to-a-live-chart-with-no-coding-skills/

I can make the database connection, and paste in the SQL, but I’m unclear how to set the script so it takes the data from the SQL.

Advertisement

Answer

Hey buddy i had the same problem, what you are trying to do is to take the tournamentid and draw for every data column a line, bar, column or whatever this problem called “pivot table” try to search over the internet, there is two different solutions for this :

  1. You can solve this in google charts api using javascript.
  2. You can solve this by nested loops(for loops) + using two selects.

Check the code below: using the second solution.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement