The PHP tree code can be nested at any layer. Can PHP tree code be nested at any layer? File: The main function used to create a tree. the passed parameter is the root node number and the root node title functioncreate_tree ($ rootid, $ roottilte) {print_par PHP tree code. any layer can be nested. File: // The main function used to create a tree. the passed parameter is the root node number and the root node title.
Function create_tree ($ rootid, $ roottilte ){
Print_parent_from_rootsortid ($ rootid, $ roottilte );
}
File: // Print the function of the root node p header
Function print_parent_from_rootsortid ($ rootid, $ roottilte ){
$ Parent_fullname = "R". $ rootid. "Parent"; file: // p Parent-level difference mark
$ Parent_id = "R". $ rootid;
$ Parent_pic = "R". $ rootid. "img ";
Echo"
Href = \ "http://www.csdn.net/expert/menu.shtm #\"
Onclick = \ "expandIt ('$ parent_id'); return false \"> src = \ "image/folderclosed000.gif \" width = 19> $ roottilte ";
Global $ cursor_tree;
$ Bottom_Flag = 0;
$ Len = strlen ($ rootid) + 2; file: // The Child encoding is the parent encoding length plus 2
$ Query = "SELECT ResourceSortNo, ResourceSortName, SectionBottomFlag
From TbSort
Where length (ResourceSortNo) = $ len and ResourceSortNo like '$ rootid %' "; file: // SQL query statement
Ora_parse ($ cursor_tree, $ query) or die;
Ora_exec ($ cursor_tree );
$ Child_fullname = "R". $ rootid. "Child"; file: // p sublevel difference mark
Echo ""; file: // Print a p sub-level header
While (ora_fetch ($ cursor_tree )){
$ Sort_No = trim (ora_getcolumn ($ cursor_tree, 0 ));
$ Sort_Title = trim (ora_getcolumn ($ cursor_tree, 1 ));
$ Bottom_Flag = trim (ora_getcolumn ($ cursor_tree, 2 ));
Print_child_from_rootsortid ($ Sort_Title, $ Sort_No, $ Bottom_Flag); file: // call the print subencoding function cyclically.
}
Echo "";
}
File: // determine whether it is the last mark and print the sub-encoding function
Function print_child_from_rootsortid ($ Section_Title, $ Section_No, $ Bottom_Flag ){
Global $ num;
$ Len = 2 * $ num + 2;
For ($ j = 0; $ j <$ len; $ j ++ ){
Echo "";
} File: // the cycle of space spacing between output nodes
If ($ Bottom_Flag = 1 ){
Echo"
$ Section_Title
";
} Else {
$ P_id = "R". $ Section_No;
$ P_pic = "R". $ Section_No. "img ";
Echo"
$ Section_Title
";
$ Child_fullname = "R". $ Section_No. "Child ";
Echo ""; file: // Print the p sub-flag header
Find_allchild_from_rootsortid ($ Section_No); file: // find sub-level content ----- nested recursive function
Echo ""; file: // Print the end of the p sub-Mark
}
}
File: // query all sub-encoding functions
Function find_allchild_from_rootsortid ($ Section_No ){
Global $ handle, $ num;
$ Num ++;
$ Cursor_ary [$ num] = ora_open ($ handle );
$ Len = strlen ($ Section_No) + 2; file: // μ? μ? ×Ó ?? ± E ± à o? 3 bytes? ?
$ Query = "SELECT ResourceSortNo, ResourceSortName, SectionBottomFlag
From TbSort
Where length (ResourceSortNo) = $ len and ResourceSortNo like '$ rootid %' "; file: // SQL query statement
Ora_parse ($ cursor_ary [$ num], $ query) or die;
Ora_exec ($ cursor_ary [$ num]);
While (ora_fetch ($ cursor_ary [$ num])
{
$ Sort_Title = trim (ora_getcolumn ($ cursor_ary [$ num], 1 ));
$ Sort_No = trim (ora_getcolumn ($ cursor_ary [$ num], 0 ));
$ Bottom_Flag = trim (ora_getcolumn ($ cursor_ary [$ num], 2 ));
Print_child_from_rootsortid ($ Sort_Title, $ Sort_No, $ Bottom_Flag); file: // print all child nodes ----- nested recursive function B
}
$ Num --;
}
?>
Why? File: // Main function for tree creation. the passed parameter is the root node number and the root node Title function create_tree ($ rootid, $ roottilte) {print_par...