本函数可以循环输出所有栏目的列表,不管栏目有几级,都会输出
折叠PHP 代码
- <?php
- require('../class/connect.php');
- require('../class/db_sql.php');
- require("../class/q_functions.php");
- require('../data/dbcache/class.php');
- $link=db_connect();
- $empire=new mysqlquery();
- //获取网站栏目
- function user_ListCats($bclassid) {
- global $empire, $dbtbpre,$class_r;
- $sql=$empire->query("select classid, classname, bclassid, islast, classpath, classurl,tbname,sonclass,classimg from {$dbtbpre}enewsclass where bclassid='$bclassid' and wburl='' order by myorder,classid");
- $num=$empire->num1($sql);
- if ($num == 0 && $bclassid == 0)//无记录
- {
- echo $GLOBALS['notrecordword'];
- return "";
- }
- if ($num == 0)
- {
- return '';
- }
- $i = 1;
- while ($r=$empire->fetch($sql))
- {
- // 如果不是终极栏目,显示其子目录
- if($_GET['toHtml']){
- $url=$_GET['root'].$r['classpath'];
- }else{
- $url=$_GET['root'].'listInfo.php?classid='.$r['classid'];
- }
- $select = $_GET['classid']==$r['classid']?'class="mm-selected"':'';
- if(emptyempty($r[islast]) )
- {
- echo '<li '.$select.'><a href="' .$url. '"><i class="iconfont icon-'.($r['classimg']?$r['classimg']:$r['tbname']).'"></i> ' . $r[classname] . '</a>';
- if($r[sonclass]){
- echo '<ul>'."\r\n";
- user_ListCats($r[classid], $showMore);
- echo '</ul>'."\r\n";
- }
- echo '</li>';
- } else {
- echo '<li '.$select.'><a href="' . $url . '"><i class="iconfont icon-'.($r['classimg']?$r['classimg']:$r['tbname']).'"></i> ' . $r[classname] . '</a></li>';
- }
- $i += 1;
- }
- }
- echo @user_ListCats();
- db_close();
- $empire=null;
- ?>