关于一级分类,二级分类的显示
记得第一次为了弄“在一级分类下面也显示,该类的子类,与子类,也显示兄弟类的时候,我用了,一个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>
<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>
关于wpsni.f78.net
php与ajax一些经验

pid id
0 1
0 2
1 3
2 4
像這樣的1 2他們的父id為0
而3 4他們的上一級id就是1 2