How to create a highchart using mysql data (PHP)?
Yes I know that this question has been asked so many times in stackoverflow in different ways. But I really cannot understand how to display mysql data in a highchart. To be honest I have been working on this for few days and could not figure it out. I am really glad if somebody could help me to sort this out
Here is my php & mysql code
data.php
<?php
require_once '../includes/database.php';
require_once '../includes/customer.php';
$customers= Customer::find_by_sql("SELECT cust_name,monthly_income FROM customer");
$rows=array();
foreach ($customers as $customer) {
$row[0]=$customer->cust_name;
$row[1]=$customer->monthly_income;
array_push($rows,$row);
}
print json_encode($rows, JSON_NUMERIC_CHECK);
?>
This will output a this kind of data series [["Madhava",55000],["Praveen",50000],["Nuwan",120000],["Thilan ",100000]]
Now I want to display this data in a bar chart which should be in following format
Monthly Income
^
|
|
|
|
Now I am going to display them in a chart I have copied below code from other website and really do not know how to change that code to make it work according to my requirement
{-code-3}
What are the changes that I should make in highcharts.php to make this work?
Answer
Answer
Solution: