如何在从sql获取数据时使用php生成动态图|

如何在从sql获取数据时使用php生成动态图|,php,Php,你好 我需要关于如何创建一个动态图的帮助,该图根据不同的日期从sql获取值 Samuel我没有php或Pear方面的经验,但我使用GraphViz,它可以做很多事情。从任何数据源创建图形 因此,php中的graphviz包装器可能对您有所帮助: 更多介绍信息 从第二个链接可以找到以下脚本: <?php // input is $name - the person to highlight in the hierarchy // connect to the database

你好 我需要关于如何创建一个动态图的帮助,该图根据不同的日期从sql获取值


Samuel

我没有php或Pear方面的经验,但我使用GraphViz,它可以做很多事情。从任何数据源创建图形

因此,php中的graphviz包装器可能对您有所帮助:

更多介绍信息

从第二个链接可以找到以下脚本:

    <?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 ");


?>

你所说的图形是什么意思

KeesDjijk的答案对于图形(即一组节点和连接)的正确含义是有效的,但你是指电子表格程序中的图表吗?如果是,请查看。

可能的副本