Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more - View Single Post - PHPlot and Arrays
View Single Post
Old 04-02-2009, 03:14 PM   #1 (permalink)
andymsuk
Junior Member
 
Join Date: Apr 2009
Posts: 1
Unhappy PHPlot and Arrays

Hi everyone.
I'm using PHPlot to draw graphs. Hopefully you are familiar with PHPlot. If not, here is a sample:
PHP Code:
$plot = new PHPlot();
 
$data = array(
  array(
''1800,   5), array(''1810,   7), array(''1820,  10),
  array(
''1830,  13), array(''1840,  17), array(''1850,  23),
  array(
''1860,  31), array(''1870,  39), array(''1880,  50),
  array(
''1890,  63), array(''1900,  76), array(''1910,  92),
  array(
''1920106), array(''1930123), array(''1940132),
  array(
''1950151), array(''1960179), array(''1970203),
  array(
''1980227), array(''1990249), array(''2000281),
    );
$plot->SetDataValues($data);
$plot->SetDataType('data-data');
$plot->DrawGraph(); 
So, as you can see, the data used by the plotter is an array of arrays.
Now, my data I want to use for this is in a database, that I access through SQL.
Here's what I have so far:
PHP Code:
while($row mysql_fetch_array($sql))
{
    
$count $count 1;
    
$Date $row['Date'];
    
$Mark $row['Mark'];
    
$blah = array(''$Date$Mark);
    
$graphdata[$count] = $blah;
};
$data = array($graphdata); //This bit is obviously instead of the example given above. 
However, this doesn't seem to work and the graph image just returns the "corrupt image" X icon.

Can anyone spot what is wrong with my code or the right way to do it, please?

Thanks in advance.

Andy
andymsuk is offline   Reply With Quote
Sponsored Links