I have been trying to generate a graph from my data in MySQL database using PHP but am stuck. Actually the plan is to have 4 graphs on a page control. At the beginning i actually thought the problem is that i didnt have the GD graphing package, but even after downloading it , there is no progress, some one help..

    You can read the data from your database and build up an image that represents the figure retrieved from your database.

    I did one a while ago that rertrieved three firgures which could be anything in the range of 0-100. Then depending on the fugure trieved, I had a bar chart with three bars respectively.

    You would need to duplicate the code below for however many bars you had:

    [code=php]if ($count1 > 0) {
    	$count1barwidth = number_format(($count1 / $totalcount) * 100, 2);
    	$graybarwidth = intval(99 - $count1barwidth);
        $count1bar = "<img src=\"images/bars/greenbar.gif\" width=\"" . $count1barwidth . "%\" height=\"8\">";
    } else {
    	$graybarwidth = 99;
    	$count1barwidth = 0;
    }
    
    $count1bar .= "<img src=\"images/bars/graybar.gif\" width=\"" . $graybarwidth . "%\" height=\"8\">";

    [/code]

    Good luck.

      Write a Reply...