无限级别菜单的实现_php实例
4953 点击·0 回帖
![]() | ![]() | |||
![]() | 明天(已是今天了,呵呵)我会提供一个测试页面让大家来看(因为我在宿舍只能拨号上网,Ip地址不固定) [/url]*/ /** 递归显示子节点函数 * * * @param $SearchPattern 查找的条件(like) * @param $BaseNum 节点的层数 */ function ListChildTree($SearchPattern,$BaseNum){ global $Tree;//声明连接数据库的句柄为全局 $Sql="select DepartmentId,DepartmentName from test where DepartmentId like $SearchPattern"; //查找孩子节点 $QueryChild=$Tree->query($Sql); while($Result=$Tree->fetch_array($QueryChild)) { //取出孩子节点 $Space=""; for($j=0;$j<((strlen($SearchPattern)/3)-$BaseNum);$j++) $Space.=" "; //设置显示节点前面的距离,这里的空格的html被这里自动替换成" "了 $ChildDepartment=trim($Result[0])."___"; $ChildSql="select count(*) from test where DepartmentId like $ChildDepartment";//查找孩子节点的孩子节点 $ChildResult=$Tree->query_first($ChildSql); $TableId="ta".trim($Result[0]); //设置表格Id $TablePic="ta".trim($Result[0])."pic"; //设置图片Id if($ChildResult[0]<1){//如果没有找到孩子节点的节点,则显示"-"图片 ?> [align=absmiddle] ![]() [table]" cellSpacing=0 cellPadding=0> [tr][td][align=absmiddle]" height=17 src="http://www.sudu.cn/info/html/edu/php/20071207/parent.gif" width=35 align=absMiddle border=0>[url=http://www.sudu.cn/info/html/edu/php/20071207/process.php?SearchPattern=] function expands(expid,picid) //显示图片张合的Js { // alert("this.document.all["+expid+"].style.display"); if(this.document.all[expid].style.display=="none") { this.document.all[expid].style.display="block"; this.document.all[picid].src="leaf.gif"; } else { this.document.all[expid].style.display="none"; this.document.all[picid].src="parent.gif"; } }
[/td][/tr][/table] | |||
![]() | ![]() |