All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
解决方案:MS,SQL数据库的连接处理问题_[SQL,Server教程]
ASP.NET中实现模版的动态加载_[Asp.Net教程]
安装MySQL5.0后出现1607异常的解决办法_php资料_编程技术
水晶报表的制作(图表)_[Asp.Net教程]
应用技巧:用.net动态创建类的实例_.net资料_编程技术
初学者来看:在PHP关于变量的使用介绍_php资料_编程技术
定义列表 Definition Lists_[Html教程]
asp.net2.0服务器控件之Label控件
使用ASP.NET中的一点体会[关于代码分离]_[Asp.Net教程]
SQL,Server与Oracle链接服务器应用_[SQL,Server教程]
Reading number is top 10 pictures
The real super beauty5
Sora aoi be huged like a bear
福利是必须的
Play for Free show breast in a world of ice and snow
A beautiful girl to bud3
Born After 90 Beijing sports university campus flower photos4
性感丰满身材火爆de美女1
男人,就要活出棱角
在加油站厕所门口看到的告示
贩卖儿童者必须判死刑
Download software ranking
Twenty piece of palm leaf
C#高级编程(第4版)
VeryCD电驴(EasyMule) V1.1.9 Build09081
WebService在.NET中的实战应用教学视频 → 第1集
Sora aoi‘s film--Lust fan wall
Tram sex maniac 2 (H) rar bag16
Sora aoi's film--cangkong_Blue.Sky
c#程序设计案例教程
Unix video tutorial11
Sora aoi, the nurse, uniform ,nursing assistant
归海一刀 published in(发表于) 2014/2/17 7:31:50 Edit(编辑)
PHP实例:PHP无限极分类_[PHP教程]

PHP实例:PHP无限极分类_[PHP教程]

PHP实例:PHP无限极分类_[PHP教程]

php无限极分类


CODE=PHP]
至于添加删除之类的功能我就不多写了!仔细看看就知道这么用了.
难的是显示方面
希望高手扩展一下!


QUOTE:
这是类
/*========================================================
类名: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 path_img .= "";
}
}
echo path_img.cata_img;
echo "";
echo row['catalog_name']."

";
path_img = "";
if(this->sun_catalog(row['catalog_id'])){
hidden_div = "style='display:none'";
echo "
";
this->catalog_show(row['catalog_id']);
echo "
";
}
}
}
}
private function sun_catalog(uid){//判断是否有子分类
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){
return true;
}else{
return false;
}
}
function catalog_add(uid,name){
//获取父id的亲缘树
this->connect();
sql = "SELECT * FROM ".this->catalog_dbname."
WHERE catalog_id = '".uid."'";
result = mysql_query(sql,this->links)
or die("错误: 第".__LINE__."行
".mysql_error());
row = mysql_fetch_assoc(result);
fid_path_number = row['catalog_path_number'];//id的数字亲缘树
fid_path_char = row['catalog_path_char'];//id的字符亲缘树
//插入数据 先插入行->再找到最新插入的id, 在依据这个id进行修改
sql = "INSERT INTO ".this->catalog_dbname."(catalog_uid,catalog_name)
VALUES(".uid.",'".name."')";
result = mysql_query(sql,this->links)
or die("错误: 第".__LINE__."行
".mysql_error());
catalog_id = mysql_insert_id();//获取自己的id
catalog_path_number = fid_path_number.":".catalog_id;//得到自己的数字亲缘数
catalog_path_char = fid_path_char.":".name;//得到自己的字符亲缘数
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("错误: 第".__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("错误: 第".__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("错误: 第".__LINE__."行
".mysql_error());
}
}
?>
[/CODE]


来源:CSDN







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.