主题:无极分类递归问题,大家帮忙看看!挺奇怪!
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from more_class",conn,3,3
set re=server.CreateObject("adodb.recordset")
re.open "select * from zb",conn,3,3
f_id=cint(request("id"))
dim MyArray(12)
i=0
'while not rs.eof
'if rs("id")=f_id then
MyArray(i)=f_id
i=i+1
'end if
'rs.movenext
'wend
dele_tree(f_id)
function dele_tree(cid)
response.Write cid&"i"
rs.movefirst
while not rs.eof
is_has=0
for j=0 to UBound(MyArray)
if MyArray(j)=rs("id") then
is_has=1
exit for
end if
next
response.Write cid&"d"
response.Write rs("parent")&"<br>"
if rs("parent")=cid and is_has=0 then
response.Write rs("id")&"<br>"
MyArray(i)=rs("id")
i=i+1
dele_tree(rs("id"))
end if
rs.movenext
wend
rs.movefirst
end function
rs.close
set rs=nothing
re.close
set re=nothing
for t=0 to UBound(MyArray)
response.Write MyArray(t)
next
%>
数据库表是一个无极分类,表结构为:
id(主键)parent(上级的主键)
我要把一个目录和它的子目录存入数组。
但是用递归无法完全执行!
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from more_class",conn,3,3
set re=server.CreateObject("adodb.recordset")
re.open "select * from zb",conn,3,3
f_id=cint(request("id"))
dim MyArray(12)
i=0
'while not rs.eof
'if rs("id")=f_id then
MyArray(i)=f_id
i=i+1
'end if
'rs.movenext
'wend
dele_tree(f_id)
function dele_tree(cid)
response.Write cid&"i"
rs.movefirst
while not rs.eof
is_has=0
for j=0 to UBound(MyArray)
if MyArray(j)=rs("id") then
is_has=1
exit for
end if
next
response.Write cid&"d"
response.Write rs("parent")&"<br>"
if rs("parent")=cid and is_has=0 then
response.Write rs("id")&"<br>"
MyArray(i)=rs("id")
i=i+1
dele_tree(rs("id"))
end if
rs.movenext
wend
rs.movefirst
end function
rs.close
set rs=nothing
re.close
set re=nothing
for t=0 to UBound(MyArray)
response.Write MyArray(t)
next
%>
数据库表是一个无极分类,表结构为:
id(主键)parent(上级的主键)
我要把一个目录和它的子目录存入数组。
但是用递归无法完全执行!