PHPBuilder - HTML_Graphs Page 2



RSS Twitter
Articles Site Operation

HTML_Graphs - Page 2

by: Tim Perdue
|
July 30, 2000

I wanted to be able to hand a simple database query to a function and have it graph it without me going to a bunch of work, so I whipped up this little function. It takes a database result and a title. The database result should be from a simple query like "select group, count(*) from table group by group". Just two columns, with the first column being the labels, and the second column being numbers.

<?php

include("class-graphs.php3");

Function 
GraphResult($result,$title) {

/*
    Takes a database result set.
    The first column should be the name,
    and the second column should be the values
*/

    /*
        db_ should be replaced with your database, aka mysql_ or pg_
    */
    
$rows=db_NumRows($result);

    if ((!
$result) || ($rows 1)) {
        echo 
"None Found.\n";
    } else {
        
$names[];
        
$values[];

        for (
$j=0$j db_NumRows($result); $j++) {
            if (
db_result($result$j0) != "" && db_result($result$j1) != "" ) {
                
$names[$j]= db_result($result$j0);
                
$values[$j]= db_result($result$j1);
            }
        }

    
/*
        This is another function detailed below
    */
        
GraphIt($names,$values,$title);
    }
}

?>

« Previous Page
1
|
2
|
3
|
4
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Tim Perdue

Comment:



Comment:

(Maximum characters: 1200). You have characters left.