发布我的无限级目录树(asp+access)!

QCB181 2006-01-10 09:51:50
数据结构如下:
'*******************************************
表 sort_class
id 自动编号
title 文本(50)
UperID 数字 默认值0 父类别ID号
SortID 数字 默认值1 当前层次编号 1 代表一级分类,以此类推
'*******************************************
程序如下
'*******************************************

<% option explicit %>
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无限级树</title>
</head>

<body>
<%
'定义全局变量
dim fatherID

function ShowSort(uID,sID)
dim rs,sql,title,i,j,upID,sortID,temp,fatherTree
upID=uID
sortID=sID
sql="select * from sort_class where SortID="&sortID&" and UperID="&upID
title=""
set rs = Server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
if not rs.eof then


for i=0 to rs.recordcount-1
if sortID>1 then
'****************************************

fatherID=upID

fatherTree=ShowFatherLine(upID,sortID-1)
'****************************************
if i = rs.recordcount-1 then
title="<br>"&temp&fatherTree&"<img src=""images/L.gif"" align=""absmiddle""><img src=""images/leaf.gif"" align=""absmiddle"">"'结束情形
else
title="<br>"&temp&fatherTree&"<img src=""images/T.gif"" align=""absmiddle""><img src=""images/leaf.gif"" align=""absmiddle"">"'一般情形
end if
else
title="<br><img src=""images/folderclosed.gif"" align=""absmiddle"">"'最高级目录树
end if

Response.Write title&rs("title")
call ShowSort(rs("ID"),sortID+1)'递归
rs.movenext
next
'else
end if
rs.close
set rs=nothing
end function

function isNext(sID,uID)
dim rs,sql
sql="select count(*) from sort_class where id>"&sID&" and SortID="&uID
'Response.Write sql
set rs=conn.execute(sql)
isNext = rs(0)
set rs=nothing
end function

function ShowFatherLine(fID,fSortID)

dim rs,sql
if fSortID=1 then'最后
sql="select count(*) from sort_class where id>"&fID&" and SortID="&fSortID
set rs=conn.execute(sql)
ShowFatherLine=parentTree(rs(0))
set rs=nothing
else

sql="select count(*) from sort_class where id>"&fID&" and SortID="&fSortID
set rs=conn.execute(sql)
ShowFatherLine=ShowFatherLine(fatherID,fSortID-1)&parentTree(rs(0))'递归

sql="select UperID from sort_class where id="&fatherID'fatherID全局变量
set rs=conn.execute(sql)
fatherID=rs(0)
set rs=nothing

end if

end function

function parentTree(TN)
if TN=0 then
parentTree="<img src=""images/blank.gif"" align=""absmiddle"">"
else
parentTree="<img src=""images/I.gif"" align=""absmiddle"">"
end if
end function
%>
<% call ShowSort(0,1)%>
</body>
</html>
<%
conn.close
set conn=nothing
%>

'*******************************************

浏览地址 http://www.b2bcc.cn/test/tree/
下载地址 http://www.b2bcc.cn/test/tree.rar
...全文
411 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
若白师妹 2006-03-01
  • 打赏
  • 举报
回复
加油
竹林听雨2005 2006-03-01
  • 打赏
  • 举报
回复
这样的好东西怎么能少了我呢?哈哈
jspadmin 2006-03-01
  • 打赏
  • 举报
回复
呵呵,直接就展开了?
linky520 2006-03-01
  • 打赏
  • 举报
回复
研究学习下 呵呵





















gatey 2006-03-01
  • 打赏
  • 举报
回复
下载看看
abcdefg3305 2006-03-01
  • 打赏
  • 举报
回复
递归法~~
smallmuda 2006-03-01
  • 打赏
  • 举报
回复
显示类别不是很难,怎么实现

比如一个A类别下有B,C,B下面有D,E等,D下面还可能分F和G。
-A
--B
--D
--F
--G
--E
--C

添加信息的时候类别选择可以为任意级别的类别。

1.获取A所有信息
2.获取B所有信息
(获取本类别以及本类别的子类别的所有关联的数据)
  • 打赏
  • 举报
回复
呵呵,多就多呗,无所的

对于楼主为什么没人来的问题很简单,这么设计的人太多了,而且比起其他人还是有不足的

如果楼主用asp只有不到1年的时间的话,是非常不错了,用了1年以上的话,还有很大的改进余地
pswdf 2006-03-01
  • 打赏
  • 举报
回复
支持!顶
是是非非 2006-03-01
  • 打赏
  • 举报
回复
这样的代码已经太多了~
feng2112 2006-03-01
  • 打赏
  • 举报
回复
mark
QCB181 2006-02-28
  • 打赏
  • 举报
回复
怎么没人来
hfkj 2006-01-10
  • 打赏
  • 举报
回复
谢谢
liuph3000 2006-01-10
  • 打赏
  • 举报
回复
mark!

http://www.goofar.com/?ID=634664011139
Only_D 2006-01-10
  • 打赏
  • 举报
回复
不知道下次优化时什么时候贴出来,能发给我一份吗?kevin_lee84@163.com
谢谢啊

优化时有没有做链接的?能不能把链接做成变量吗?不同的人用在不同的地方,文件名肯定不同,修改起来更烦
hebhd 2006-01-10
  • 打赏
  • 举报
回复
烦.接点分.就不能看树..

数据结构看多了烦死
ybfqlyq 2006-01-10
  • 打赏
  • 举报
回复
好,有空測試一下。
nicholas34 2006-01-10
  • 打赏
  • 举报
回复
哇 是Q哥的作品啊,一定支持你的啊
gatey 2006-01-10
  • 打赏
  • 举报
回复
路过看看
QCB181 2006-01-10
  • 打赏
  • 举报
回复
欢迎大家提出问题,下次加进js,可以收起、展开
加载更多回复(3)
演示:http://asp2004.net/temp/treemenu/ 下载地址:http://asp2004.net/temp/treemenu.rar 关键代码: <% set conn=server.createobject("ADODB.CONNECTION") connstr="DBQ="+server.mappath("db1.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" conn.open connstr function menu(id) set rs=server.CreateObject("adodb.recordset") sql="select * from menu where id1="&id&" order by url,id" rs.open sql,conn,1,1 if rs.recordcount=0 then rs.close set rs=nothing exit function end if response.write("") i=1 while not rs.eof if len(rs("url"))>0 then if i=rs.recordcount then menutype="file1" else menutype="file" end if menuname=""&rs("menuname")&"" onmouseup="" else if i=rs.recordcount then menutype="menu3" listtype="list1" onmouseup="with(eval('id"&rs("id")&"'))if(style.display==''){style.display='none';this.className='menu3';}else{style.display='';this.className='menu4';}" else menutype="menu1" listtype="list" onmouseup="with(eval('id"&rs("id")&"'))if(style.display==''){style.display='none';this.className='menu1';}else{style.display='';this.className='menu2';}" end if menuname=rs("menuname") end if %> <%if len(rs("url"))<3 then%> " style="display:none"> <% end if rs.movenext i=i+1 wend response.write("
<%menu(rs("id"))%>
") rs.close set rs=nothing end function %> =========<em>无限</em><em>级</em><em>目录</em><em>树</em>=========http://bbs.<em>asp</em>2004.net http://bbs.asp2004.net/提供最新下载《管理
<% menu 0 conn.close set conn=nothing %>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧