P? $ Handleora_plogon (sender, password) ordie (database connection failed !); $ Cursorora_open ($ handle); file: // public cursor $ cursor_treeora_open ($ handle); file: // create a dedicated tree cursor $ num0; file: // Save the cursor value variable ora_com
P> $ Handle = ora_plogon (sender, password) or die ("database connection failed! ");
$ Cursor = ora_open ($ handle); file: // public cursor
$ Cursor_tree = ora_open ($ handle); file: // create a dedicated tree cursor
$ Num = 0; file: // Save the cursor value variable
Ora_commiton ($ handle); file: // automatically enable oracle submission
?>
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 div header function of the root node
Function print_parent_from_rootsortid ($ rootid, $ roottilte ){
$ Parent_fullname = "R". $ rootid. "Parent"; file: // div Parent-level difference sign
$ 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: // div sublevel difference sign
Echo ""; file: // Print a div sublevel 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"
Http://www.csdn.net/expert/exchange.asp\ "target = forum> $ Section_Title
";
} Else {
$ P_id = "R". $ Section_No;
$ P_pic = "R". $ Section_No. "img ";
Echo"
Http://www.csdn.net/expert/exchange.asp\ "onclick = \" expandIt ('$ p_id'); return false \ "> $ Section_Title
";
$ Child_fullname = "R". $ Section_No. "Child ";
Echo ""; file: // Print the div sub-flag header
Find_allchild_from_rootsortid ($ Section_No); file: // find sub-level content ----- nested recursive function
Echo ""; file: // Print the tail of the div 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 --;
}
?>