PHPlot and Arrays - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-02-2009, 03:14 PM   #1 (permalink)
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, 08:20 AM   #2 (permalink)
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
Old 05-04-2011, 02:50 AM   #3 (permalink)
Junior Member
 
danieljames123's Avatar
 
Join Date: May 2011
Posts: 73
Thumbs up

very good question
danieljames123 is offline   Reply With Quote
Reply

Tags
arrays , php , phplot

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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



» 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 02:53 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting