JPgraph in php question

Posted on 2009-02-23
Last Modified: 2013-12-13
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

Question by:ftpphptest1
    LVL 142

    Accepted Solution

    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

    LVL 14

    Expert Comment

    by:Ionut A. Tudor
    why using php 4 version ? I suggest you a better tool for graphs:

    Author Comment

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now