欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

jquery 多级菜单:php无限分类读取多级菜单

程序员文章站 2022-05-13 21:45:34
...
//数据库表

include "comm.php";
//获取分类菜单
$arr=getTree();
$arrone=getFlone(59);
$arrtwo=getFltwo(93);
$arrmenu=getFlmenu(59);
print_r($arrmenu);
//获取分类树
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;
}
//活动一级分类 注意在这*分类id为 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;
}
//活动二级分类
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;
}
//循环获取菜单,此数据库*父分类id为 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] => 国内新闻
[fltitle] => 国内新闻
[3] => 0-59
[flpath] => 0-59
[4] => 国内新闻
[fldes] => 国内新闻
[5] => 国内新闻
[keyword] => 国内新闻
[two] => Array
(
[0] => Array
(
[0] => 98
[flid] => 98
[1] => 93
[flpid] => 93
[2] => 时政
[fltitle] => 时政 本文链接http://www.cxybl.com/html/wlbc/Php/20121120/34051.html