asp 무한 등급(재 귀적 호출)

데이터베이스 필드:id(자동 번호),classname(메뉴 이름),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
%>

좋은 웹페이지 즐겨찾기