无限级分类递归法(超简单)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<select name="categoryid">
<%
'表名:category
'字段名:categoryid,category,OrderID,parentID
TimesDB="../Data/#TimesShop.asp"
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&TimesDB&"")
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open connstr
sort(0)
dim ii
ii=0
sub sort(selec)
sql="select * from category where ParentID = "&selec&" order by OrderID"
Set Rs1=Conn.Execute(sql)
do while not rs1.eof
if selec=0 then
%>
<option value="<%=int(rs1("categoryid"))%>">|…<%=rs1("category")%></option>
<%
else
%>
<option value="<%=int(rs1("categoryid"))%>">|<%=string(ii," ")%>|…<%=rs1("category")%></option>
<%
end if
ii=ii+1
sort rs1("categoryid")
ii=ii-1
rs1.movenext
loop
rs1.close
Set Rs1 = Nothing
end sub
%>
</select>