jquery Multilevel Menu: PHP Unlimited category read Multilevel menu

Source: Internet
Author: User
Tags foreach array sql query

Database tables

<?php
Include "comm.php";
Get category Menu
$arr =gettree ();
$arrone =getflone (59);
$arrtwo =getfltwo (93);
$arrmenu =getflmenu (59);
Print_r ($arrmenu);
Get the taxonomy tree
function Gettree () {
Global $db;
$sql = "Select Flid,flpid,flpath,fltitle,fldes,keyword from Fenlei order by Flid";
$rs = $db->query ($sql);
$data =array ();
while ($row = $db->fetch_array ($rs)) {
$data []= $row;
}
return $data;
}
Activity level Classification Note in this top-level category ID of 59
function Getflone ($flpid) {
Global $db;
$sql = "SELECT * from Fenlei where flpid={$flpid} ORDER by Flid";
$rs = $db->query ($sql);
$data =array ();
while ($row = $db->fetch_array ($rs)) {
$data []= $row;
}
return $data;
}
Activity Level Two classification
function Getfltwo ($flpid) {
Global $db;
$sql = "SELECT * from Fenlei where flpid={$flpid} ORDER by Flid";
$rs = $db->query ($sql);
$data =array ();
while ($row = $db->fetch_array ($rs)) {
$data []= $row;
}
return $data;
}
Loop Fetch menu, this database top-level parent category ID is 59
function Getflmenu ($flpid) {
Global $db;
$arr =getflone ($flpid);
foreach ($arr as & $v) {
$ARRT =getflone ($v ["Flid"]);
foreach ($arrt as & $VL) {
$arrtt =getflone ($VL ["Flid"]);
$VL ["tt"]= $arrtt;
}
$v ["Two"]= $ARRT;
}
return $arr;
}
?>
Array
(
[0] => Array
(
[0] => 93
[Flid] => 93
[1] => 59
[Flpid] => 59
[2] => Domestic News
[Fltitle] => Domestic News
[3] => 0-59
[Flpath] => 0-59
[4] => Domestic News
[Fldes] => Domestic News
[5] => Domestic News
[keyword] => domestic news
[Two] => Array
(
[0] => Array
(
[0] => 98
[Flid] => 98
[1] => 93
[Flpid] => 93
[2] => politics
[Fltitle] => Politics this article links http://www.cxybl.com/html/wlbc/Php/20121120/34051.html

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.