I am trying to pass data from a mysql query into an array in order to create a graph in JPGraph.
Conceptually it seems very simple! I have hard coded the data from the query and it creates the graph, the problem appears to be the way in which I am attempting to pass data into the array for JPGraph.
JPGraph uses a $variable = array (data) to operate.. how does one pass data (whether pre formatted or created via concatenate loops in a query) into an array() statement?
My code that half works...
<?php
include ("../jpgraph.php");
include ("../jpgraph_line.php");
mysql_connect("foo", "bar", "foo");
mysql_select_db("foo");
//whip out preformatted data from the db (in format 22.45,45.23 etc etc)
$row = mysql_query ("SELECT * FROM fullresult where id=1");
// fetch the data required (only 1 row in db at present)
$result = mysql_fetch_array($row);
$driver1 = $result['laps'];
// test the output (which works)
echo $driver1,"<br>";
// crunch point! this is where I attempt to make an array
// Normal Usage = $ydata = array(22.45,45.23,etc,etc);
// My attempt to extract data..
$ydata = array($driver1);
//OR
$ydata[] = $driver1
// Neither works!
//After this it all works..
// Create the graph. These two calls are always required
$graph = new Graph(800,300);
$graph->SetScale("textlin");
// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor("blue");
$lineplot->SetWeight(1);
// Add the plot to the graph
$graph->Add($lineplot);
$graph->SetShadow();
// Display the graph
$graph->Stroke();
?>
Very grateful for any pointers.
Oo