答案:
//boardid 文章ID(自动增长) parentid 父级ID 默认为0 (0代表最高级) boardtype 菜单名. 其它字段省 ---------------------------------------------- | boardid | type | parentid | ---------------------------------------------- 核心代码: //先取出最高级(parentid=0)的分类 <% set rs1=server.createobject("adodb.recordset") sql1="select * from board where parentid=0 order by id" rs1.open sql1,conn,1,1 if rs1.eof or rs1.bof then response.write"还没论坛分类!" else while not rs1.eof id1=rs1("id") type1=rs1("boardtype") parentid1=rs1("parentid") call recursion(id1,type1,parentid1) rs1.movenext wend end if rs1.close set rs1=nothing %> <% sub recursion(id,m_boardtype,m_parentid) '递归调用函数,生成一个类别代码 set rs=server.createobject("adodb.recordset") sql="select * from board where parentid="&id rs.open sql,conn,1,1 while not rs.eof id0=rs("id") type0=rs("boardtype") parentid0=rs("parentid") call recursion(id0,type0,parentid0) rs.movenext wend rs.close set rs=nothing %> |
上一个:ASP+ACCESS实现的无限级目录树
下一个:用asp实现无限级分类