began to search the internet for the Unlimited classification of ASP, but ASP.net almost found, and found is also linked with the TreeView.
Find the ASP version of the code there are several, the original is similar to the use of recursive algorithm.
The table structure is as follows:
Table name is classname
ID PRIMARY Key
ID of the parent class corresponding to the SID
ClassName the name of the corresponding category.
Code Snippet One:
1function loadNextType(upid,rank)
2 dim rs
3 set rs="select * from classname where sid="&upid
4 do while not rs.eof
5 loadNextType=loadNextType &rs("ClassName") &"<br>"& string("-",rank) & loadNextType(rs("id"),rank+1)
6 rs.movenext
7 loop
8end function调用时:response.write(loadNextType (0,0))
Another piece of code is the same as the above principle. It's just a way of showing the tree structure.
Code Snippet Two:
1'定义第一级分类
2sub mainfl()
3 dim rs
4 set rs=conn.execute ("select id,F_id,F_name from ClassNae where sid=0 order by id desc")
5 if not rs.eof then
6 do while not rs.eof
7 response.write rs(2) & "<br>"
8 call subfl(rs(0)," |- ") '循环子级分类
9 rs.movenext
10 if rs.eof then exit do '防上造成死循环
11 loop
12 end if
13end sub
14'定义子级分类
15sub subfl(fid,strdis)
16 dim rs1
17 set rs1=conn.execute("select id,sid,ClassName from ClassName where sid="&fid&" order by id desc")
18 if not rs1.eof then
19 do while not rs1.eof
20 response.write rs1(2) & "<br>"
21 call subfl(rs1(0)," "&strdis) '递归子级分类
22 rs1.movenext
23 if rs1.eof then
24 rs1.close
25 exit sub
26 end if
27 loop
28 end if
29end sub