bambinou1980 Posted August 14, 2015 Share Posted August 14, 2015 Hello all, I would like to use the chart library called Morris.js, it seems quite pretty but I have a ltitle problem, stilll new to PHP..... I need a bit of help figuring this one out please, Morris.js seems to only read the data into jason format, I have always heard about json, took a little course tonight but I am still unsure on how to pull some data from mysql, transform it into an array, then from that array, encode it into json. My first question is, let's say I have a query and create an array from it(hope this is right..) $query = "SELECT * FROM id, sales, customer, months ORDER BY months;$months = array();while(($row = mysqli_fetch_assoc($result))) {$months[] = $row['months']; $sales[] = $row['sales'];} Now that I have the array, how to I change it into json? It is my understanding that the generated json file will have to go into a folder and from there I will output the data from that folder into morris.js, am I correct? I am sorry but the morris.js explanations are a little bit complicated for me right now. Thanks! Ben Quote Link to comment Share on other sites More sharing options...
Barand Posted August 14, 2015 Share Posted August 14, 2015 json_encode Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.