php - Load Json Data into an AmChart

528

I beginner to Amchart and am test load data in Amchart using php this is my format json

[{"date":"2018-01-01","column-1":"5187"},{"date":"2018-01-02","column-1":"15790"},{"date":"2018-01-03","column-1":"15826"},{"date":"2018-01-04","column-1":"17026"},{"date":"2018-01-05","column-1":"17908"},{"date":"2018-01-01","column-2":"2143"},{"date":"2018-01-02","column-2":"6192"},{"date":"2018-01-03","column-2":"6106"},{"date":"2018-01-04","column-2":"6532"},{"date":"2018-01-05","column-2":"7000"}]

and this is my code

var data1 = <?php
include('connect.php');
$data = array();
$arr = array();
$query = "SELECT * FROM shell_table_graph";
$db = mysql_query($query);
while($rows = mysql_fetch_assoc($db)) {
     $data[] = ['column' => $rows['column'], 'formula' => $rows['calculation']];
}
foreach($data as $rowss) {
    $formula = $rowss['formula']; 
    $query = "SELECT Date, SUM(".$formula.") AS Formula FROM eod_split_interval WHERE Date BETWEEN '2018-01-01' AND '2018-01-05' GROUP BY Date";
    $db = mysql_query($query);
    while($r = mysql_fetch_assoc($db)) {
         $arr[] = ['date' => $r['Date'], $rowss['column'] => $r['Formula']];
        $code = json_encode($arr);
    }

}
echo $code;
 ?>;

People are also looking for solutions to the problem: mysql - XML Output in PHP (UTF-8)

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.