天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

php 無限極分類

復制代碼 代碼如下:
<?php
/*========================================================
類名: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__."行<br>".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__."行<br>".mysql_error());
if(mysql_num_rows($result) > 0){
while ($row = mysql_fetch_assoc($result)){  
if($this->sun_catalog($row['catalog_id'])){//判斷有沒有子分類
$cata_img = "<img id = 'img".$row['catalog_id']."' src='./img/last_node.jpg' ōnclick='click_catalog(".$row['catalog_id'].")'/>";
}else{
$cata_img = "<img src='./img/sp.jpg'/>";
}
$path = explode(":",$row['catalog_path_number']);
if(count($path) > 1){
for($i=1;$i<count($path);$i++){
$path_img .= "<img src='./img/sp.jpg'/>";
}
}
echo $path_img.$cata_img;
echo "<a class='menu' href = 'Javascrīpt:send_id(".$row['catalog_id'].")'>";
echo $row['catalog_name']."</a><br>";
$path_img = "";
if($this->sun_catalog($row['catalog_id'])){  
$hidden_div = "style='display:none'";  
echo "<div id = 'div".$row['catalog_id']."' ".$hidden_div.">";  
$this->catalog_show($row['catalog_id']);
echo "</div>";
}  
}
}  
}
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__."行<br>".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__."行<br>".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__."行<br>".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__."行<br>".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__."行<br>".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__."行<br>".mysql_error());
}
}
?>

php技術php 無限極分類,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 久久人妻少妇嫩草AV无码 | 丰满人妻按磨HD | 一区三区在线专区在线 | 用震蛋调教女性下面视频 | 亲胸摸下面激烈免费网站 | 免费啪视频观试看视频 | 国产精品AV色欲蜜臀在线 | 天天干夜夜曰 | 午夜福利自怕 | 美女动态图真人后进式 | 日本2021免费一二三四区 | 免费成人高清在线视频 | 亚洲欧洲自拍偷拍 | 久久99这里只有精品 | 亚洲色欲啪啪久久WWW综合网 | 99久久精品久久久久久清纯 | 动漫人物差差差30分钟免费看 | 精品无人区麻豆乱码无限制 | 影音先锋亚洲AV少妇熟女 | 欧美黑大炮18p | 无码一卡二卡三卡四卡 | 国产成人啪精视频精东传媒网站 | 久久AV国产麻豆HD真实 | 日韩欧美一区二区中文字幕 | 我和黑帮老大第365天第2季在线 | 动漫美女性侵 | 麻豆免费观看高清完整视频 | 人人爽天天碰狠狠添 | 久久亚洲精品无码A片大香大香 | sihu国产精品永久免费 | 成人高清护士在线播放 | 亚洲人成7777 | 少妇内射视频播放舔大片 | 国产99久久久欧美黑人刘玥 | 日本高清免费一本在线观看 | 成人在线免费视频 | 久久精品国产午夜伦班片 | 长篇高h肉爽文丝袜 | 九九在线免费视频 | 香港论理午夜电影网 | 一二三四在线观看韩国 |