I was able to get some help on my original question in order to get a concatenated JSON output from mysql. So now I have a JSON array that I'm trying to get to display in a Morris JS line chart that sits on a PHP page.
Currently this is what a print_r($rows) returns:
Array ( [0] => Array ( [json_data_records] => {"dateRecorded": "2018-04-02 21:15:56","sensor2":64.96,"sensor1":60.91} ) [1] => Array ( [json_data_records] => {"dateRecorded": "2018-04-02 21:25:58","sensor2":64.51,"sensor1":60.91} ) [2] => Array ( [json_data_records] => {"dateRecorded": "2018-04-02 21:36:00","sensor2":64.06,"sensor1":60.91} ) [3] => Array ( [json_data_records] => {"dateRecorded": "2018-04-02 21:46:02","sensor2":63.61,"sensor1":60.35} ) [4] => Array ( [json_data_records] => {"dateRecorded": "2018-04-02 21:56:05","sensor2":63.27,"sensor1":60.46} ) ) 1
But I believe the chart is looking for a structure more like:
[
{"dateRecorded": "2018-04-02 00:20:00","sensor2":69.91,"sensor1":68.11},
{"dateRecorded": "2018-04-02 00:30:08","sensor2":69.69,"sensor1":68.00}
]
I tried to set my data input in the chart config to data: <?php echo $rows;?> but I get an error:
PHP Notice: Array to string conversion
If I copy each line of the mysql output and put it into the data setting of the chart config, everything prints out as I would like so I know I have the right structure and config set, just need some help getting it from the array to formatted. Would I use some sort of a for loop to iterate through the array and print out each line?