Unlimited menu implementation _ PHP Tutorial

Source: Internet
Author: User
Unlimited menu implementation .? * 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 ),
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 = "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


Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.