一棵php的類樹(支持無限分類)
Jun 21, 2016 am 09:15 AM最近問無限分類的類樹問題比較多,所以一高興自己寫了一個(gè),我剛寫完的,大家用用看,看看怎么實(shí)現(xiàn)起來更快,更簡單,把你的樹也貼出來(要只查詢一次數(shù)據(jù)庫的)
這是一棵分類列表的類樹, 支持無限分類
一個(gè)分類下面可以同時(shí)有"包含子類的分類"和"最終分類";
唯一的優(yōu)點(diǎn)是*****只需要進(jìn)行一次的數(shù)據(jù)庫*****查詢.
樣子不是很好看,不過可以自定義修改,可以自己定義css加里面
緩存方面還沒有作,可以自己補(bǔ)上
下面例子的目錄結(jié)構(gòu)是這樣的。
|--Catagory.php
|--images----tree.jsp
|--images----treeopen.gif
|--images----treeclose.gif
|--images----line.gif
/****************tree.jsp********************/
function expand(id){
node = document.all('node'+id);
if(node.style.display==''){
node.style.display = 'none';
document.images('img'+id).src = imgopen;
}else{
node.style.display = '';
document.images('img'+id).src = imgclose;
}
}
/****************Catagory.php********************/
define('CATAGORY_TREE_EXPEND_NONE',0);
define('CATAGORY_TREE_EXPEND_ALL',1);
class Catagory{
//基礎(chǔ)分類數(shù)據(jù)
var $treeData = array();
//分類的等級結(jié)構(gòu)數(shù)組,以分類的id值作為數(shù)組的關(guān)鍵字
var $treePList = array();
//自分類對應(yīng)上級類的關(guān)系
var $treeCList = array();
/*
* 這個(gè)是大分類的模板
*
* __id__ 分類的編號
* __name__ 分類的名稱
* __image__ 分類前面顯示的圖像名稱 $imgOpen or $imgClose
* __open__ 分類當(dāng)前是否是展開的
* __inner__ 子分類顯示的位置

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Detailed explanation and installation guide for PiNetwork nodes This article will introduce the PiNetwork ecosystem in detail - Pi nodes, a key role in the PiNetwork ecosystem, and provide complete steps for installation and configuration. After the launch of the PiNetwork blockchain test network, Pi nodes have become an important part of many pioneers actively participating in the testing, preparing for the upcoming main network release. If you don’t know PiNetwork yet, please refer to what is Picoin? What is the price for listing? Pi usage, mining and security analysis. What is PiNetwork? The PiNetwork project started in 2019 and owns its exclusive cryptocurrency Pi Coin. The project aims to create a one that everyone can participate

How to delete node with nvm: 1. Download "nvm-setup.zip" and install it on the C drive; 2. Configure environment variables and check the version number through the "nvm -v" command; 3. Use the "nvm install" command Install node; 4. Delete the installed node through the "nvm uninstall" command.

How to handle file upload? The following article will introduce to you how to use express to handle file uploads in the node project. I hope it will be helpful to you!

How to package nodejs executable file with pkg? The following article will introduce to you how to use pkg to package a Node project into an executable file. I hope it will be helpful to you!

This article will share with you Node's process management tool "pm2", and talk about why pm2 is needed, how to install and use pm2, I hope it will be helpful to everyone!

Authentication is one of the most important parts of any web application. This tutorial discusses token-based authentication systems and how they differ from traditional login systems. By the end of this tutorial, you will see a fully working demo written in Angular and Node.js. Traditional Authentication Systems Before moving on to token-based authentication systems, let’s take a look at traditional authentication systems. The user provides their username and password in the login form and clicks Login. After making the request, authenticate the user on the backend by querying the database. If the request is valid, a session is created using the user information obtained from the database, and the session information is returned in the response header so that the session ID is stored in the browser. Provides access to applications subject to

npm node gyp fails because "node-gyp.js" does not match the version of "Node.js". The solution is: 1. Clear the node cache through "npm cache clean -f"; 2. Through "npm install -g n" Install the n module; 3. Install the "node v12.21.0" version through the "n v12.21.0" command.

This article uses the case of reading and writing files and processing paths to learn about the fs file module and path module in Node. I hope it will be helpful to everyone!
