JPgraph in php question

i want to get the example for using JPgraph php 4 version
as i find many problems in the teaching example when i run it

i want to have an example to get the data from MySQL table
and output the data in line chart

Who is Participating?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
here is a script using jpgraph
include ("../jpgraph/jpgraph.php");
include ("../jpgraph/jpgraph_pie.php"); 
// we will split by country as by the argument ($country) 
$country = @$_GET["country"];
$range_min = @$_GET["range_min"];
$range_max = @$_GET["range_max"]; 

if (!$range_min) { $range_min = 10000; }
if (!$range_max) { $range_max = 100000000; } 

$sql = "select, count(*) c from account a join accounttype at on at.uuid = a.accounttypeid where like ''$country%'' group by order by ";
$sql = "select name, sum(c) c from ( select case when c < $range_min then ''others'' else name end name, c from ( $sql ) ) group by name having sum(c) <= $range_max  "; 

$data = array();
$keys = array();
$labels = array(); 
if ($rows = mysql_query($query))
  while ($row = mysql_fetch_array($rows))
    $keys[] = $row["NAME"];
    $data[] = $row["C"];
    $labels[] = $row["C"] . "\n(%.1d%%)";
// Create the Pie Graph. 
$graph = new PieGraph(600,300,"auto");
// Set A title for the plot
if (!$country) { $country = 'All'; } 
$graph->title->Set("Account Types ($country)");

// Create
$p1 = new PiePlot($data);


Open in new window

Ionut A. TudorPHP ProgrammerCommented:
why using php 4 version ? I suggest you a better tool for graphs:
ftpphptest1Author Commented:
i wanna a example which can show different element agianst time  in a pine chart ,
do u all have any example?

the data is from the table in MySQL
table element1
table element2 etc
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.