目录树的构成:
数据表仅仅用typeid,typename,fatherid三列实现. 新 骑 兵 www.pcfancs.com.cn
<%
set Rs=server.CreateObject("adodb.recordset")
Rs.open "Select * From cls where fatherID='0'",conn,1,1 '查询根目录,即父目录为0
%>
<select name="fatherid" id="fatherid">
<option value="0" selected>请选择栏目</option>
<%
do while Not Rs.eof
Response.Write ("<option value="""&Rs("typeid")&""">"&Rs("typename")&"</option>"&chrb(13) & chrb(10)) '输出
call subtree("┠",Rs("typeid")) '调用当前目录下所有子栏目
Rs.movenext
loop
rs.close
%>
</select>
<%
Sub subtree(tree,t_id) '这个子程序是实现子栏目调用的.
set rs1=conn.execute("Select * from cls where fatherID='"&t_id&"'") 查询父目录为t_id的所有栏目.
do while Not Rs1.eof
Response.Write ("<option value="""&Rs1("typeid")&""">"&tree&Rs1("typename")&"</option>"&chrb(13) & chrb(10))
call subtree(tree&"┝",Rs1("typeid")) '调用当前栏目的所有子栏目!
rs1.movenext
loop
rs1.close
set rs1=nothing
End sub
%>