那位熟悉无限极分类的高手来指教一下。语言不限
我的数据库设计如下:ID(顶层,非空)SID(从,可空)
搜索 id有,sid无id相同值的的ID集合A,该集合作为第一层
在此集合A做循环得出一个sid集合,条件是id有,sid也不为空。
在得到的sid集合,再做一次循环,条件是id=sid and SID不为空
我的算法如上了。
那位有更简单的算法,指教一下 好象看天书般。。。。。。。。。帮顶。 不明白啊。。。。。。。。 艾,还素要使用到递归
最后 select id,tlnamefrom topiclist where id not in (select sid from topiclist where sid !='');
select sid,tlname from topiclist where id=3 and sid!='';
select sid,tlnam from topiclist where id='上一条sql语句的sid特定数' and sid !='';
$result=执行第一条语句
while($row=mysql_fetch_array($result,MYSQL_ASSOC)){
printf($row['tlname']);
$re2=执行第二条语句;
while($row2=mysql_fetch_array($re2,MYSQL_ASSOC)){
printf("_____"$row['tlname']);
doext();
}
}
function doext(){
$re3=执行第三条语句;
if(mysql_num_rows($re)>1){
while($row2=mysql_fetch_array($re3,MYSQL_ASSOC)){
printf("_________" $row['tlname']);
doext();
}
}
} 长天都不知道的,还有人知道吗 绝对是天书。。。。。。。。。。 ID , PID(父ID)
根默认PID=0
这样简单点 都素高淫哈 :)
页:
[1]