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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.