复制代码 代码如下:
/*========================================================
类名:catalog
功能:无限分级类
方法:
树形显示分类
catalog_show($id) //参数$id 递归调用
流程:找到父分类为0所有根分类-> 一直递归取得所有分类并显示
添加分类
catalog_add($uid,$name) //$uid 父id //$name 分类名
流程:依据$uid,在此id下添加一个新子id
删除分类
catalog_del($uid)//参数 $uid 数要删除的分类
修改分类
catalog_set($id,$name) //参数 $id 要修改的分类 //参数 $name 新的分类名
变量:
$config //数据库信息-> host,user,pass,dbname
$catalog_dbname //分类数据库名
数据库:
catalog_id //分类的自然序号
catalog_uid //分类的父分类
catalog_name //分类名
catalog_path_number //亲缘树数字形式 0:1:2
catalog_path_char //亲缘树字符形式 分类1:分类1.1:分类1.1.1
参照文章 http://www.phpchina.com/12823/viewspace_4468.html
========================================================*/
class catalog{
var $config;
var $catalog_dbname;
var $links;
private function connect(){
$this->links = mysql_connect($this->config['host'],$this->config['user'],$this->config['pass']) or die("错误: 第".__LINE__."行
".mysql_error());
mysql_select_db($this->config['dbname'],$this->links);
mysql_query("SET NAMES gb2312");
}
function catalog_show($uid = 0){
$this->connect();
$sql = "Select * FROM ".$this->catalog_dbname. "
Where catalog_uid = ". $uid ."
orDER BY catalog_id ";
$result = mysql_query($sql,$this->links) or die("错误: 第".__LINE__."行
".mysql_error());
if(mysql_num_rows($result) > 0){
while ($row = mysql_fetch_assoc($result)){
if($this->sun_catalog($row['catalog_id'])){//判断有没有子分类
$cata_img = "";
}else{
$cata_img = "";
}
$path = explode(":",$row['catalog_path_number']);
if(count($path) > 1){
for($i=1;$i";
}
}
echo $path_img.$cata_img;
echo "";
echo $row['catalog_name']."
";
$path_img = "";
if($this->sun_catalog($row['catalog_id'])){
$hidden_div = " style="max-width:90%";
echo "
$this->catalog_show($row['catalog_id']);
echo "
}
}
}
}
private function sun_catalog($uid){//Determine whether there is a subcategory
$sql = "Select * FROM ".$this->catalog_dbname. "
Where catalog_uid = " . $uid ."
orDER BY catalog_id ";
$result = mysql_query($sql,$this->links) or die("Error: No. ".__LINE__." line
".mysql_error()) ;
if(mysql_num_rows($result) > 0){
return true;
}else{
return false;
}
}
function catalog_add($uid,$name){
//Get the affinity tree of the parent id
$this->connect();
$sql = "Select * FROM ".$this->catalog_dbname."
Where catalog_id = '".$uid."'";
$result = mysql_query($sql ,$this->links)
or die("Error: Line ".__LINE__."
".mysql_error());
$row = mysql_fetch_assoc($result);
$fid_path_number = $row[ 'catalog_path_number'];//The numeric affinity tree of id
$fid_path_char = $row['catalog_path_char'];//The character affinity tree of id
//Insert data Insert the row first -> Then find the latest inserted id, in Modify based on this id
$sql = "Insert INTO ".$this->catalog_dbname."(catalog_uid,catalog_name)
VALUES(".$uid.",'".$name."')";
$ result = mysql_query($sql,$this->links)
or die("Error: Line ".__LINE__."
".mysql_error());
$catalog_id = mysql_insert_id();//Get Your own id
$catalog_path_number = $fid_path_number.":".$catalog_id;//Get your own numeric affinity number
$catalog_path_char = $fid_path_char.":".$name;//Get your own character affinity number
$sql = "Update '".$this->catalog_dbname."'
SET
catalog_path_number = '".$catalog_path_number."',
catalog_path_char = '".$catalog_path_char."'
Where
catalog_id = ".$catalog_id;
mysql_query($sql,$this->links)
or die("Error: Line ".__LINE__."
".mysql_error());
}
function catalog_del($id){
$ this->connect();
$sql = "Delete FROM ".$this->catalog_dbname."
Where catalog_id = ".$id;
mysql_query($sql,$this->links)
or die ("Error: Line ".__LINE__."
".mysql_error());
}
function catalog_set($id,$name){
$this->connect();
$sql = " Update ".$this->catalog_dbname."
SET
catalog_name = '".$name."'
Where
catalog_id = ".$id;
mysql_query($sql,$this->links)
or die ("Error: Line ".__LINE__."
".mysql_error());
}
}
?>
The above introduces the Infinitus China Co., Ltd. php Infinitus classification, including the content of Infinitus China Co., Ltd. I hope it will be helpful to friends who are interested in PHP tutorials.

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio


Hot AI Tools

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

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

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
