Jump to content

Mysql jpgraph array


Milka

Recommended Posts

Hi all,

 

This is a bit of a newbie question, I am trying to replace my file array with a mysql array.

 

What I am hoping to do is return all entry's in the "total" table as an array, that I can then input into jpgraph "LinePlot($my-total-array)"

 

How do I return my "total" row as an array that I can use to create my LinePlot($array)

 

Many thanks,

M

 

 

 

<?php
include ("../../jp/src/jpgraph.php");
include ("../../jp/src/jpgraph_line.php");

 

//MySL conn

$con=mysqli_connect("db","user","password","testdb");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM testdb");

while($row = mysqli_fetch_array($result))
{

//        
//echo  . $row['total'] . ;

 


}

 

 

// JPGRAPH

function trim_value(&$value)
{
$value = trim($value);
}

$Filearray = file("../../array.txt");

array_walk($Filearray, 'trim_value');


// Create the graph. These two calls are always required
$graph = new Graph(750,250,"auto");
$graph->SetScale("linelin");
$graph->SetMarginColor('#6495ED');
$graph->title->Set("totals");
$graph->subtitle->Set("all");

$graph->xaxis-> title->Set("TIME " );
$graph->yaxis-> title->Set("% Total " );


$graph->SetShadow();

$graph->title->SetColor("white");
$graph->subtitle->SetColor("white");
$graph->xaxis-> title->SetColor("black");
$graph->yaxis-> title->SetColor("black");

// Create the linear plot
$lineplot=new LinePlot($Filearray);
$lineplot->SetColor("red");

?>

 

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.