Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 04-02-2009, 02: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
Old 06-26-2009, 07:20 AM   #2 (permalink)
dave.albert
Junior Member
 
Join Date: Jun 2009
Posts: 1
Default Re: PHPlot and Arrays

Try something like

PHP Code:
$data = array(); 

$num 0;

while (
$row mysql_fetch_assoc($result)) 
{
   
$data[$num] = array($row["ins_group"],$row["los"]);
   
$num += 1;   

Quote:
Originally Posted by andymsuk View Post
Hi everyone.
I'm using PHPlot to draw graphs. Hopefully you are familiar with PHPlot.
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
dave.albert is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View:
Points Per Thread:
Points Per Reply:



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 08:28 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums