hello i need help about how to create a dynamic graph that gets values from sql depending on different dates
Samuel
I have no experience with php or Pear but I do with GraphViz and it can do a lot. Creating graphics from about any data source.
So this graphviz wrapper in php might be helpful to you : http://pear.php.net/manual/en/package.images.image-graphviz.example.php
more introduction information here
from that second link you can find the following script:
<?php
// input is $name - the person to highlight in the hierarchy
// connect to the database
if(!($dblink=mysql_connect("shares.cems.uwe.ac.uk","cwstudent","cwstudent"))) {
print("mysql_connect failed<br>\n");
exit;
}
if(!(mysql_select_db("Emp",$dblink))) {
print("cannot connect to database $db");
exit;
}
// get the hierarchy data
$query = "select e.ename as ename, m.ename as mname from emp e , emp m where e.mgr = m.empno;";
if(!($dbresult = mysql_query($query,$dblink))) {
print("<b>query failed</h4><br>\n");
print(mysql_error() . "<br>\n");
}
$f .= "digraph hier {\n";
if (isset($name) ) $f .= " $name [fillcolor=red1, shape=box];\n";
while($rep=mysql_fetch_object($dbresult)) {
$f .= "$rep->mname -> $rep->ename; \n";
}
$f .="}";
mysql_close($dblink);
//set output to be GIF
header("Content-type: image/gif");
//execute the dot program and pass thru the output back to the client
passthru("echo '$f' | /usr/local/graphviz/bin/dot -Tgif ");
?>
For more detail on how to program it exactly you should get this question to stackoverflow.com
What do you mean by graphs?
KeesDjijk's answer is valid for the correct meaning of graphs (i.e. a set of nodes and connections) but do you mean charts like you get in spreadsheet programs? If so, have a look at jpgraph.