asp无限分级(递归调用)
程序员文章站
2023-11-07 11:35:46
数据库字段:id(自动编号),class_name(菜单名),parentid(父菜单id) 复制代码 代码如下:<% dim m m=0 ca...
数据库字段:id(自动编号),class_name(菜单名),parentid(父菜单id)
<%
dim m
m=0
call showtree(0)%>
<%
sub showtree(parentid)
dim s
m=m+1
dim rs
set rs = server.createobject("adodb.recordset")
sql="select class_id,class_name from [wms_class] where class_father_id="&cint(parentid)
rs.open sql,conn,1,1
if rs.eof and m = 1 then
response.write("该频道暂无栏目")
end if
do while not rs.eof
response.write rs(0)
for n=1 to m
if n = m and m = 1 then
response.write ("╋")
elseif n = 1 then
response.write (" ")
elseif n = m then
response.write ("├")
else
response.write ("│")
end if
next
response.write rs(1)&"<br>"
call showtree(rs(0))
m=m-1
rs.movenext
loop
end sub
%>
复制代码 代码如下:
<%
dim m
m=0
call showtree(0)%>
<%
sub showtree(parentid)
dim s
m=m+1
dim rs
set rs = server.createobject("adodb.recordset")
sql="select class_id,class_name from [wms_class] where class_father_id="&cint(parentid)
rs.open sql,conn,1,1
if rs.eof and m = 1 then
response.write("该频道暂无栏目")
end if
do while not rs.eof
response.write rs(0)
for n=1 to m
if n = m and m = 1 then
response.write ("╋")
elseif n = 1 then
response.write (" ")
elseif n = m then
response.write ("├")
else
response.write ("│")
end if
next
response.write rs(1)&"<br>"
call showtree(rs(0))
m=m-1
rs.movenext
loop
end sub
%>
上一篇: php实现中文字符截取防乱码方法汇总
下一篇: 湿疹喝什么好,这些你千万要进来看看