本帖最后由 jordan102 于 2011-03-11 14:51:51 编辑

解决方案 »

  1.   

    给你个php无限分类的树类吧   1. <?php  
       2. class tree {  
       3.     var $data = array();  
       4.     var $child = array(-1 => array());  
       5.     var $layer = array(-1 => -1);  
       6.     var $parent = array();  
       7.     var $countid = 0;  
       8.     function tree() {}  
       9.       
      10.     function setNode($id, $parent, $value) {  
      11.           
      12.         $parent = $parent?$parent:0;  
      13.       
      14.         $this->data[$id] = $value;  
      15.         $this->child[$parent][]  = $id;  
      16.         $this->parent[$id] = $parent;  
      17.           
      18.         if(!isset($this->layer[$parent])) {  
      19.             $this->layer[$id] = 0;  
      20.         } else {  
      21.             $this->layer[$id] = $this->layer[$parent] + 1;  
      22.         }  
      23.     }  
      24.       
      25.     function getList(&$tree, $root= 0) {  
      26.         foreach($this->child[$root] as $key => $id) {  
      27.             $tree[] = $id;  
      28.             if($this->child[$id]) $this->getList($tree, $id);  
      29.         }  
      30.     }  
      31.       
      32.     function getValue($id) {  
      33.         return $this->data[$id];  
      34.     }  
      35.       
      36.     function reSetLayer($id) {  
      37.         if($this->parent[$id]) {  
      38.             $this->layer[$this->countid] = $this->layer[$this->countid] + 1;  
      39.             $this->reSetLayer($this->parent[$id]);  
      40.         }  
      41.     }  
      42.       
      43.     function getLayer($id, $space = false) {  
      44.         //重新计算级数  
      45.         $this->layer[$id] = 0;  
      46.         $this->countid = $id;  
      47.         $this->reSetLayer($id);  
      48.         return $space?str_repeat($space, $this->layer[$id]):$this->layer[$id];  
      49.     }  
      50.       
      51.     function getParent($id) {  
      52.         return $this->parent[$id];  
      53.     }  
      54.       
      55.     function getParents($id) {  
      56.         while($this->parent[$id] != -1) {  
      57.             $id = $parent[$this->layer[$id]] = $this->parent[$id];  
      58.         }  
      59.           
      60.         ksort($parent); //按照键名排序  
      61.         reset($parent); //数组指针移回第一个单元  
      62.       
      63.         return $parent;  
      64.     }  
      65.       
      66.     function getChild($id) {  
      67.         return $this->child[$id];  
      68.     }  
      69.       
      70.     function getChilds($id = 0) {  
      71.         $child = array();  
      72.         $this->getList($child, $id);  
      73.           
      74.         return $child;  
      75.     }  
      76. }  
      77.   
      78. ?>  
      

  2.   

    看图片上那个下拉框,当前是点击linux相册。我想让linux相册和三个子类都不显示!有什么办法吗?