|
HTML_Graphs
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, $j, 0) != "" && db_result($result, $j, 1) != "" ) {
$names[$j]= db_result($result, $j, 0);
$values[$j]= db_result($result, $j, 1);
}
}
/*
This is another function detailed below
*/
GraphIt($names,$values,$title);
}
}
?>
| Comments: | ||
| rectangular coordinats system graphs. | mitchell penneau | 06/08/05 12:18 |
| php upload one image | tndvrs | 03/01/05 12:53 |
| Tell me how to install GD into a Unix (Darwin | jeanloui | 09/21/03 05:16 |
| tell me about apache and unix in | laban | 09/20/02 09:48 |
| RE: JPGraph does this - but how... | Markus | 06/05/02 06:29 |
| RE: JPGraph does this - but how... | Markus | 06/04/02 14:01 |
| RE: Create a bar chart in PHP / HTML? | fareed | 06/01/02 01:14 |
| creating a GIF | Tom Fritsch | 12/10/01 18:43 |
| RE: Create a bar chart in PHP / HTML? | Thomasson | 10/21/01 12:35 |
| graphs | Per Kummervold | 08/06/01 05:58 |
| RE: Create a bar chart in PHP / HTML? | Deepak | 07/27/01 02:51 |
| JPGraph does this - but how... | Owen Lees | 07/08/01 14:07 |
| Create a bar chart in PHP / HTML? | Jacky Hung | 06/01/01 08:32 |
| RE: Tell me ,can I use the GD library in PHP41pl2 | zealousness | 05/29/01 06:18 |
| Html Graphs | Sean Dowell | 05/04/01 11:58 |
| on the fly gif graphs | George Kesarios | 03/10/01 12:14 |
| GifPix.class - without GD or tables | Roberto Bertó | 02/19/01 03:55 |
| interesting and very useful | katherine | 12/28/00 21:27 |
| way cool site | nduati githae | 12/21/00 02:54 |
| How can I use this with templates? | Gary Smith | 11/21/00 20:48 |
| I have done it before. | Ahmad Anvari | 11/08/00 15:37 |
| Enhancements to wrapper (2) | Rob Watkins | 09/06/00 09:43 |
| Enhancements to wrapper (1) | Rob Watkins | 09/06/00 09:40 |
| Tell me ,can I use the GD library in PHP41pl2 | Ting.Xu | 07/14/00 18:05 |
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly. | ||


