关于一级分类,二级分类的显示 不指定

admin , 2006/04/28 03:17 , 代码片段,演示也有 , Comments(1) , Reads(4210) , Via Original
记得第一次为了弄“在一级分类下面也显示,该类的子类,与子类,也显示兄弟类的时候,我用了,一个if else会开写,先判断id是不是父类的,如果是,显示所有的子类,如果子类,先得到父类的id,然后在用父类的id把下面的子类给输出,今天晚上想了又想,终于用sql来完成这个问题了

   <div id="headline">
     <%
    exec="select * from cat where ( pcatid="&id&" or  pcatid in(select pcatid from cat where  id="&id&" and not (pcatid=0) order by list asc)) and view=1 order by list asc"
        set cat=server.createobject("adodb.recordset")
      cat.open exec,conn,1,1
      do while not cat.eof
      response.Write img&"<a href=class.asp?id="&cat("id")&">"&cat("catname")&"</a> "
      cat.movenext
      loop
      cat.close
      set cat=Nothing
    %>
   </div>
Tags: , ,
rs
2007/04/15 13:16
能写个ASP二级分类的思路吗?谢谢
Else replied on 2007/04/15 13:32
二級分類下,建 一個類為父類,然後把下面子類的父id指向那裡,
pid   id
0     1
0     2
1     3
2     4
像這樣的1 2他們的父id為0
而3 4他們的上一級id就是1 2
Pages: 1/1 First page 1 Final page
Add a comment

Nickname

Site URI

Email

Enable HTML Enable UBB Enable Emots Hidden Remember [Login] [Register]