Jump to content

Creating an array from a selected column based based on order


bambinou1980

Recommended Posts

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.