The code of the PHP tree, you can nest any layer _php foundation
Source: Internet
Author: User
PHP Tree code, you can nest any layer.?
file://establishes the main function of the tree, passing the argument as the number of the root node and the caption of the root node
function Create_tree ($rootid, $roottilte) {
Print_parent_from_rootsortid ($rootid, $roottilte);
}
file://a function to print the root node div header
function Print_parent_from_rootsortid ($rootid, $roottilte) {
$parent _fullname= "R". $rootid. " Parent "; File://div Parent Difference Flag
$parent _id= "R". $rootid;
$parent _pic= "R". $rootid. " IMG ";
echo "
<div class=parent id= $parent _fullname><a
Href=\ "Http://www.csdn.net/expert/menu.shtm#\"
Onclick=\ "ExpandIT (' $parent _id '); Return false\ ">Src=\ "image/folderclosed000.gif\" width=19> $roottilte </A></DIV>;
Global $cursor _tree;
$Bottom _flag=0;
$len =strlen ($rootid) +2; file://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 Child Difference Flag
echo "<div class=child id= $child _fullname>"; file://Print a DIV sub-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://Loop call Print child encoding function
}
echo "</DIV>";
}
file://to determine whether it is a last-level flag, and print a child-encoded 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://a loop of spacing between output nodes
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.