当前位置:K88软件开发文章中心编程语言AspAsp01 → 文章内容

asp+access实现的无限级分类

减小字体 增大字体 作者:wangsdong     来源:asp编程网  发布时间:2018-12-30 8:31:40

思路是使用递归循环显示数据库中的内容
代码:
<
%
'*****************************************
' 功能:树形显示无限级分类
' 开发: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 "&
nbsp
"
 
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



asp+access实现的无限级分类