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
https://forums.phpfreaks.com/topic/276940-mysql-jpgraph-array/
Share on other sites

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.