@ AuthorYHC: when creating an asynchronous tree, each tree must have an & amp; #39; id & amp; #39; attribute. This attribute will be submitted back to the server to retrieve the child node data. view the Demo Tree [html] & lt; ulid & quot; tt & quot; class & quot; easyui-tree & quot; url & quot; tree2_g
@ Author YHC
When creating an asynchronous tree, each tree must have an 'id' attribute. This will be submitted back to the server to retrieve the data of the subnode.
View Demo
Create a Tree
[Html]
Url = "tree2_getdata.php">
Url = "tree2_getdata.php">
Server code
[Php]
$ Id = isset ($ _ POST ['id'])? Intval ($ _ POST ['id']): 0;
Include 'conn. php ';
$ Result = array ();
$ Rs = mysql_query ("select * from nodes where parentId = $ id ");
While ($ row = mysql_fetch_array ($ rs )){
$ Node = array ();
$ Node ['id'] = $ row ['id'];
$ Node ['text'] = $ row ['name'];
$ Node ['state'] = has_child ($ row ['id'])? 'Closed ': 'Open ';
Array_push ($ result, $ node );
}
Echo json_encode ($ result );
Function has_child ($ id ){
$ Rs = mysql_query ("select count (*) from nodes where parentId = $ id ");
$ Row = mysql_fetch_array ($ rs );
Return $ row [0]> 0? True: false;
}
Author: yhc13429826359