PHPlot Problems
Posted: Wed Oct 22, 2008 8:05 am
Having alot of problems when using PHPlot with MySQL.
I am trying to display a graph which will change when the information in the MySQL
database is changed. I already know how to display a graph with static information in it.
This is the code i have so far:
Some of this code was taken from examples, so i dont fully understand the Syntax, but i have the general idea.
Can Anyone help?
I am trying to display a graph which will change when the information in the MySQL
database is changed. I already know how to display a graph with static information in it.
This is the code i have so far:
Code: Select all
<?php
//Include phplot.php
require_once 'C:Appserv/www/PHPlot/phplot/PHPlot.php'
//Plot new phplot image
$plot = new PHPlot ();
//Set plot and data type
$plot->SetPlotType('lines');
$plot->SetDataType('text-data');
//Select testdb and assign data to variable $data
$r = mysql_query($db, 'SELECT * from sales');
if (!$r) exit();
$data = array();
$n_rows = mysql_num_rows($r);
for ($i = 0; $i < $n_rows; $i++) $data[] = mysql_fetch_row($r, $i);
...
$plot->SetDataValues($data);
//Set the look of the graph
$plot->SetXDataLabelPos('none');
$plot->SetLineWidths(3);
$plot->SetDrawXGrid(True);
//Draw the graph
$plot->DrawGraph();
?>
Some of this code was taken from examples, so i dont fully understand the Syntax, but i have the general idea.
Can Anyone help?