呵呵,帮我看看这个程序,我本来想使递归调用的,可是我在中间改了参数的值,它只能循环一次,这可怎么办?非常低级的问题!
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<?
/* 本函数的目的是从数据库的类库读出所有的大类、小类,以便于进行类别的增、删*/
/* 函数中的参数$last_id用来记录小类所对应上一级类的一个标志,$class_grade用来记录这个小类的级别*/
function search($last_id,$class_grade){
 require("common/db_connect.php");
 require("common/config.php");
 $char_sql="select * from $table_name5 where last_id='$last_id' and class_grade='$class_grade';";
 $result=@mysql_db_query($db_name,$char_sql,$link_message);
 $num=@mysql_num_rows($result);
 ?>
 <table border="1" bordercolorlight="#cccccc" bordercolordark="#FFFFFF">
 <?
 if($num==0){
 exit();
 }
 for($i=1;$i<=$num;$i++){
 $record=@mysql_fetch_object($result);
 $last_id=$record->this_id;
 $class_grade=$record->class_grade+1;
 echo"<tr><td>";
 echo $record->class_name;
 echo"</td><td>";
 search($last_id,$class_grade);
 echo"</td></tr>";
 }//for
 echo"</table>";
}//function$last_id1='00';
$class_grade1='1';
search($last_id1,$class_grade1);
?>

解决方案 »

  1.   

    这个问题我已经解决过了。在news.5470.cn中就采用了无限分级的方式。给你一个提示吧,因为程序很长。
    写一个递归函数,里面用二维数组进行存放每一次递归的值。最后可以得到一个树。
    另外我还做了一个简单的分类处理,如果只有一级那么就没有目录名链接,否则给出链接,当点击链接时进入下一级。这个帖子给出了导航是如何做的。
    http://expert.csdn.net/Expert/topic/1730/1730904.xml?temp=.1228449
      

  2.   

    另外你如果是要一个树话,那么在www.5470.org.cn中的首页上有你想要的效果。
      

  3.   

    think you all,这个问题目前已经解决了,结贴
      

  4.   

    Thank you all,I have solved this problem now! Thank you,Thank you!