服务器端取出数据IE端通过treeview ACTIVEX控件形成树

解决方案 »

  1.   

    表结构(有些字段你不一定用得上,不过大致就是这样):
    CREATE TABLE CATEGORY_TABLE (
       TYPE_ID int(11) NOT NULL auto_increment,
       TYPE_NAME varchar(40) NOT NULL,
       PID int(11) DEFAULT '0' NOT NULL,
       CHILDNUM int(11) DEFAULT '0' NOT NULL,
       LEVEL smallint(6) DEFAULT '0' NOT NULL,
       HAVE_CHILD char(1) DEFAULT '0' NOT NULL,
       CAT_CARD_ID int(11),
       PRIMARY KEY (TYPE_ID),
       UNIQUE TYPE_ID (TYPE_ID, TYPE_NAME),
       KEY PID (PID, TYPE_ID, LEVEL, TYPE_NAME)
    );程序较为复杂,如果你要可以留电子邮件。我给你发过去。
      

  2.   

    [email protected]
    就是我的了。。谢谢
      

  3.   

    我开始编了一个,不过好像数据结构有问题,实现很慢,有明显的等待,我再本地运行的好像有一秒吧,我就放弃了,
    能否给我也发一份[email protected]
      

  4.   

    我也想要,我的EMAIL是:[email protected]
      

  5.   

    定义结构
    id  --树id
    pid --父id 如果没有父则填0
    name --树名存到数据库中然后下面的函数处理
    function select_tree($main_id)
    {
       select * from tree where pid=$main_id order by id;
       fetch each
       {
          echo name;
          select_tree(id);
       }
    }
    伪代码,不知你能否看懂
      

  6.   

    我是初学者,学写了一个,不知能不能如你的法眼,你可以根据需要改一下再用,
    如果有根好的办法,通知我一声
    <? 
    //+-先建立几个树壮类----------------------------------------------------------- 
    class menu 

        var $name ; 
        var $href ; 
        var $items ; 
        function menu($name,$href='') 
        { 
            $this->name=$name; 
            $this->href=$href ; 
        } 
        function add($name,$href='') 
        { 
            $n=count($this->items); 
            if(is_object($name)) 
                $this->items[$n]=$name ; 
            else 
            { 
                $this->items[$n]['name']=$name ; 
                $this->items[$n]['href']=$href ; 
            } 
        } 
        function show($space='&nbsp;&nbsp;')      
        {  
            global $PHP_SELF,$img_open,$img_close ; 
                $path=basename($PHP_SELF)."?path="; 
            echo  "\n".$space.$img_open."<a href='".$path.$this->href."' >".$this->name."</a><br>\n" ; 
        $space=$space."&nbsp;&nbsp;" ; 
             if(is_array($this->items)){ 
                  while(list(,$item)=each($this->items)) 
               { 
                if(is_object($item)) 
                     $item->show($space) ; 
                else 
                   echo $space.$img_close."<a href='".$path.$item['href']." '>".$item['name']."</a><br>\n";     
               } 
            } 
     } //end of fun 
    }  //end of class //+------ 一个递归函数,用来打开目录--------------------------------------- 
    function get_path_tree($n=0) 
    {  
        global $path ; 
        $plist=explode('/',$path); 
        if(count($plist)<$n) return ; 
        $curr_path=$plist[0]; 
        for($i=1;$i<=$n;$i++)  
            $curr_path=$curr_path."/".$plist[$i] ; 
           $mynode=new menu($plist[$n],$curr_path); 
     if(!file_exists($curr_path)) 
                return  ; 
           $mydir=opendir($curr_path); 
       while($file=readdir($mydir)) 
        {  
           if(is_dir($file)&&$file!='.' && $file!='..') 
            { 
             if($file==$plist[$n+1]) 
                {   
                    $sub_node=get_path_tree($n+1); 
                    $mynode->add($sub_node); 
                } 
                else                 
                 $mynode->add($file,$curr_path."/".$file); 
                   
                } 
        } 
      closedir($mydir);  
      return $mynode;  
     } 
      //+------这里是输出要得两个图片----------------------------------------------------------------- 
    $img_open="<img src='img/open.gif' >"; 
    $img_close="<img src='img/close.gif' >"; 
     
     //+-----------下面是实例-------------------------------------
     if($path=='')
        $path='.' ;
    $mytree=get_path_tree(0); //从 本目录起
    $mytree->show(); ?>