PHP Unlimited Classification Read multi-level menu _php Tutorial

Source: Internet
Author: User
Database tables



Include "comm.php";

Get category Menu

$arr =gettree ();
$arrone =getflone (59);
$arrtwo =getfltwo (93);
$arrmenu =getflmenu (59);
Print_r ($arrmenu);


Get classification 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 classification 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 get 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 [' both ']= $ARRT;
}
return $arr;
}

?>
Include "comm.php";

Get category Menu

$arr =gettree ();
$arrone =getflone (59);
$arrtwo =getfltwo (93);
$arrmenu =getflmenu (59);
Print_r ($arrmenu);


//Get the Taxonomy tree www.2cto.com
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 is "Getflone
Function" ($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 two-level 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 Get menu, this database top-level parent category ID is getflmenu
function ($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 [' both ']= $ARRT;
}
return $arr;
}

?>

[PHP]

 
[HTML] 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
[a] = = Array
(
[0] = = Array
(
[0] = 98
[Flid] = 98
[1] = 93
[Flpid] = 93
[2] = politics
[Fltitle] = politics
[3] = 0-59-93
[Flpath] = 0-59-93
[4] = politics
[Fldes] = politics
[5] = politics
[Keyword] = politics
[TT] + = Array
(
[0] = = Array
(
[0] = 102
[Flid] = 102
[1] = 98
[Flpid] = 98
[2] = = Medical
[Fltitle] = Medical
[3] = 0-59-93-98
[Flpath] = 0-59-93-98
[4] = = Medical
[Fldes] = Medical
[5] = = Medical
[Keyword] = medical
)

[1] = = Array
(
[0] = 103
[Flid] = 103
[1] = 98
[Flpid] = 98
[2] = health
[Fltitle] = health
[3] = 0-59-93-98
[Flpath] = 0-59-93-98
[4] = health
[Fldes] = health
[5] = health
[Keyword] = health
)

)

)

[1] = = Array
(
[0] = 99
[Flid] = 99
[1] = 93
[Flpid] = 93
[2] = People's livelihood
[Fltitle] = People's livelihood
[3] = 0-59-93
[Flpath] = 0-59-93
[4] = People's livelihood
[Fldes] = People's livelihood
[5] = People's livelihood
[keyword] = People's livelihood
[TT] + = Array
(
[0] = = Array
(
[0] = 104
[Flid] = 104
[1] = 99
[Flpid] = 99
[2] = tax
[Fltitle] = taxes
[3] = 0-59-93-99
[Flpath] = 0-59-93-99
[4] = tax
[Fldes] = taxes
[5] = tax
[Keyword] = taxes
)

[1] = = Array
(
[0] = 105
[Flid] = 105
[1] = 99
[Flpid] = 99
[2] = = Housing
[Fltitle] = housing
[3] = 0-59-93-99
[Flpath] = 0-59-93-99
[4] = = Housing
[Fldes] = housing
[5] = = Housing
[Keyword] = housing
)

)

)

)

)

[1] = = Array
(
[0] = 96
[Flid] = 96
[1] = 59
[Flpid] = 59
[2] = entertainment News
[Fltitle] = Entertainment News
[3] = 0-59
[Flpath] = 0-59
[4] = entertainment News
[Fldes] = Entertainment News
[5] = Entertainment News
[keyword] = entertainment news
[a] = = Array
(
[0] = = Array
(
[0] = 100
[Flid] = 100
[1] = 96
[Flpid] = 96
[2] = gossip
[Fltitle] = gossip
[3] = 0-59-96
[Flpath] = 0-59-96
[4] = gossip
[Fldes] = gossip
[5] = gossip
[Keyword] = gossip
[TT] + = Array
(
)

)

[1] = = Array
(
[0] = 101
[Flid] = 101
[1] = 96
[Flpid] = 96
[2] = Star
[Fltitle] = Star
[3] = 0-59-96
[Flpath] = 0-59-96
[4] = Star
[Fldes] = Star
[5] = Star
[Keyword] = star
[TT] + = Array
(
)

)

)

)

[2] = = Array
(
[0] = 97
[Flid] = 97
[1] = 59
[Flpid] = 59
[2] = foreign news
[Fltitle] = foreign news
[3] = 0-59
[Flpath] = 0-59
[4] = foreign news
[Fldes] = foreign news
[5] = foreign news
[keyword] = foreign news
[a] = = Array
(
[0] = = Array
(
[0] = 106
[Flid] = 106
[1] = 97
[Flpid] = 97
[2] = USA
[Fltitle] = USA
[3] = 0-59-97
[Flpath] = 0-59-97
[4] = USA
[Fldes] = USA
[5] = USA
[Keyword] = USA
[TT] + = Array
(
[0] = = Array
(
[0] = 107
[Flid] = 107
[1] = 106
[Flpid] = 106
[2] = New York
[Fltitle] = New York
[3] = 0-59-97-106
[Flpath] = 0-59-97-106
[4] = New York
[Fldes] = New York
[5] = New York
[keyword] = New York
)

)

)

)

)

)


Excerpt from chaojie2009 's column

http://www.bkjia.com/PHPjc/478378.html www.bkjia.com true http://www.bkjia.com/PHPjc/478378.html techarticle //database table? PHP include comm.php;//Get Category Menu $arr =gettree (); $arrone =getflone ($arrtwo =getfltwo); $arrmenu = Getflmenu (59); Print_r ($arrmenu); Get classification Tree ...

  • Related Article

    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.