search
Homephp教程php手册jquery 多级菜单:php无限分类读取多级菜单


//数据库表

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



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use