日期:2011-04-28  浏览次数:20478 次


    function bars($code,$title,$url){
        $path    =    "";
        $msg    =    "缺少必须参数..";
        if(empty($code)){
            return $msg;
        }
        if($url[0]=="*"){
            $cl=substr($url,1,strlen($url));
        }else{
            $cl="a01";//默认链接的class--为了修改颜色
        }
        $sql=$this->getsql("select * from path where symbol='$code'");
        $path_="<a href=\"".$sql[0][url]."\" class=$cl>".$sql[0][title]."</a>";//当前目录与名称
        for($int_a=0;$int_a<$sql[0][level];$int_a++){
            $sql_=$this->getsql("select * from path where id='".$sql[0][vlevel]."'");
            $pathi[]="<a href=\"".$sql_[0][url]."\" class=$cl>".$sql_[0][title]."</a> → ";
            $sql[0][vlevel]=$sql_[0][vlevel];
            if($sql_[0][id]==$sql_[0][vlevel]){    
                break;
            }
        }
        reset($pathi);
        sort($pathi);
        while(list($key,$values)=each($pathi)){
            $path.=$values;
        }
        $path.=$path_;
        if($title!="" && $url!=""){
            $path.=" → <a href=\"$url\">$title</a>";
        }
        return $path;
    }

————————————————————————————————
以上为本人所使用的栏目导航类...(原创,非盗版!)
————————————————————————————————
表格结构为:
CREATE TABLE path (
  id int(8) unsigned NOT NULL auto_increment,
  symbol varchar(10) NOT NULL default 'a-1',
  level int(8) unsigned NOT NULL default '1',
  vlevel int(8) unsigned default '1',
  title varchar(50) NOT NULL default '',
  url varchar(100) NOT NULL default '/',
  PRIMARY KEY  (id),
  UNIQUE KEY id (id),
  KEY id_2 (id,symbol,level,vlevel)
) TYPE=MyISAM;

________________________________________________________