思路是使用递归循环显示数据库中的内容
代码:
< %
'*****************************************
' 功能:树形显示无限级分类
' 开发:asp编程网
' 网址:www.aspprogram.cn
' 作者:wangsdong
' 注:原创文章,转载请保留此信息,谢谢
'*****************************************
depath=0
function fl(parent_id)
set rs1 =server.createobject("adodb.recordset")
sql="select title,id from cat where parent_id="&parent_id&" order by sort_order asc"
set rs1=conn.execute(sql)
If rs1.eof Then
Else
do while not rs1.eof
title = rs1("title")
id = rs1("id")
for i=1 to depath
response.write " "
next
response.write title
response.write "<br>"
sql2="select title,id from cat where parent_id="&parent_id&" order by sort_order asc"
set rs2=server.createobject("adodb.recordset")
set rs2=conn.execute(sql2)
if not rs2.eof then
depath=depath+3
call fl(id)
end if
rs2.close
set rs2=nothing
depath=depath-3
rs1.movenext
loop
End If
rs1.close
set rs1=nothing
end function
call fl(0)
% >
代码下载地址:http://www.aspprogram.cn/soft.asp?id=60