& Lt ;? * Many of my friends have asked questions about the unlimited menu (in theory, there are still some levels. after all, they are restricted by convenient conditions, such as the type of database fields ), I used the code provided by the boss (nagging) to write an unlimited menu, but I felt that the effect was not very good (visually), so I took advantage of & quot; quiet at night & quot; write this & quot; unlimited menu & quot;. In fact, the principle is very simple, mainly because of the design of data tables
Tomorrow (today, huh, huh) I will provide a test page for you to see (because I can only dial up the Internet in the dormitory and the IP address is not fixed)
*/
/** Recursively display subnode functions
*
*
* @ Param $ search condition (like)
* @ Param $ number of layers of the BaseNum node
*/
Function ListChildTree ($ SearchPattern, $ BaseNum ){
Global $ Tree; // declare that the database connection handle is global.
$ SQL = "select DISTINCT mentid, DepartmentName from test where distinct mentid like '$ SearchPattern'"; // search for child nodes
$ QueryChild = $ Tree-> query ($ SQL );
While ($ Result = $ Tree-> fetch_array ($ QueryChild) {// retrieve the child node
$ Space = "";
For ($ j = 0; $ j <(strlen ($ SearchPattern)/3)-$ BaseNum); $ j ++)
$ Space. = ""; // set the distance before the display node. here, the Space html is automatically replaced ""
$ ChildDepartment = trim ($ Result [0]). "___";
$ ChildSql = "select count (*) from test where perform mentid like '$ ChildDepartment'"; // you can find the child node of a child node.
$ ChildResult = $ Tree-> query_first ($ ChildSql );
$ TableId = "ta". trim ($ Result [0]); // you can specify a table Id.
$ TablePic = "ta". trim ($ Result [0]). "pic"; // set the image Id
If ($ ChildResult [0] <1) {// if the node of the child node is not found, the "-" image is displayed.
?>
"Class =" F1 ">
?>
',' ') "Style =" cursor: hand ">" src = http://www.cncms.com/"parent.gif" border = "0" align = "absmiddle" width = "35" height = "17"> "class =" F1 ">
ListChildTree ($ ChildDepartment, $ BaseNum); // recursively call the function itself to display other child nodes} // End if?>
} // End function?>
Unlimited menu test
|