Welcome Guest, Not a member yet? Register   Sign In
Need help about Jpgraph or Panaci/Panachart
#1

[eluser]James Bolongan[/eluser]
Hi, I need some help on how to store in array the data from a database...Like the data below, I want it that the data must come from the database.


// Setup Chart
$ydata = array(11,3,8,12,5,1,9,13,5,7); // the data must be from the database....please help me... :-)



I already run the Jpgraph and the Panachart and I can update the data but I do not know on how to update the data that is from the database. Please someone help me. I am new to this Jpgraph and Panachart.
#2

[eluser]Pascal Kriete[/eluser]
I've never used this software, but as it is, it's probably easiest to just store a comma seperated list in a text field.

From array to csv:
Code:
$ydata = array(11,3,8,12,5,1,9,13,5,7);
$csv = implode('|' , $ydata);
// put csv into array

From csv to array:
Code:
$csv =  /// get from db
$ydata = explode('|', $csv);

Hope that answers your question.
#3

[eluser]James Bolongan[/eluser]
Thanks to your idea inparo. I try to use the implode function but Jpgraph does not work...

Here is my sample code:

Code:
$h2O =  $this->db->query("SELECT  percent_h2O  FROM cement");
$ydata = explode('|', $h2O);

It does not work...Then I try to result it in a row
Code:
$query =  $this->db->query("SELECT  * FROM cement");
      foreach($query->result_array() as $row){
        $h2O = $row['percent_h2O '];
        $ydata = explode('|', $h2O);
      }
Still it doesnt work.

Thanks a lot to inparo...It really helps me in coding that is more simple and easy....It is so useful in my other application right now.

I still need help about the Jpgraph on how to update the data that is from the db. I dont know whats the correct syntax. The problem is the parsing of the data from the db...




Theme © iAndrew 2016 - Forum software by © MyBB