动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   Asp → 阅读文章

 用ASP实现网站的“目录树”管理

作者:无从考证 来源:学习在线 
阅读 2196 人次 , 2006-2-15 14:15:00 

数据库结构(共使用了两个表)

1.tblCategory
字段名 类型
Root binary 说明树关或开(目录的根)
ID 自动编号 关键字
Sort integer 识别该字段内容的整数(如果root是开状态sort为0)表示显示的目录的顺序
Name text(255)可以包含html中的标识符
HREF text(255) 允许空

2.tblPages
ID 自动编号
Sort integer 关键字
Name text(255)
HREF text(255)

3.default.htm
〈html$#@62;
〈head$#@62;
〈title$#@62;JavaScript/" target="_blank">JavaScript Tree Control Template〈/title$#@62;
〈/head$#@62;
〈frameset cols="210,*"$#@62;
?〈frame src="tree.asp" name="TOC"$#@62;
?〈frame src="main.htm" name="basefrm"$#@62;
〈/frameset$#@62;
〈/html$#@62;

4.main.htm
〈head$#@62;〈title$#@62;〈/title$#@62;〈/head$#@62;
〈body$#@62;
〈h2$#@62;Start Page〈/h2$#@62;
〈/body$#@62;
〈/html$#@62;

5.tree.asp
Set conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
conn.open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("toc.mdb")

strsql = "SELECT tblCategory.Root, tblCategory.[ID], tblCategory.Sort AS CatSort, tblPages.sort AS LinkSort, tblCategory.[Name] AS CatName, tblCategory.HREF AS CatURL, tblPages.[Name] AS LinkName, tblPages.href AS LinkURL FROM tblCategory LEFT JOIN tblPages ON tblCategory.[ID] = tblPages.[ID] ORDER BY tblCategory.root ASC, tblCategory.Sort, tblPages.sort"

rs.open strsql, conn, 2, 2

if not rs.eof then rs.movefirst
currentID = "" %$#@62;
〈html$#@62;
〈head$#@62;
〈link rel="stylesheet" href="ftie4style.css"$#@62;
〈!-- Infrastructure code for the tree --$#@62;
〈script src="ftiens4.js"$#@62;〈/script$#@62;
〈!-- Execution of the code that actually builds the specific tree --$#@62;
〈script$#@62;
USETEXTLINKS = 1
〈%
D hile Not Rs.EOF
If Rs("Root") = True Then %$#@62;
foldersTree = gFld("〈%= Rs("CatName") %$#@62;", "〈%= Rs("CatURL") %$#@62;")
〈% Else %$#@62;
aux1 = insFld(foldersTree, gFld("〈%= Rs("CatName") %$#@62;", "〈%= Rs("CatURL") %$#@62;"))
〈% currentID = Rs("ID")
savedID = Rs("ID")
Do While currentID = savedID and not rs.eof
if Rs("LinkName") 〈$#@62; "" Then %$#@62;
insDoc(aux1, gLnk(0, "〈%= Rs("LinkName") %$#@62;", "〈%= Rs("LinkURL") %$#@62;"))
〈%
end if
Rs.MoveNext
if not rs.eof then currentID = Rs("ID")
Loop
End If
if currentID = "" then rs.movenext
Loop %$#@62;
〈/script$#@62;
〈script$#@62;
initializeDocument()
〈/script$#@62;
〈base target="basefrm"$#@62;
〈title$#@62;〈/title$#@62;
〈/head$#@62;
〈body bgcolor="white"$#@62;
〈/body$#@62;
〈/html$#@62;

  
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:用ASP做一个分页程序
· 下一篇:网页在线人数统计的做法
· ASP的技术特点与使用方法
· RecordSet分页例子
· Sql表数据操作
· ASP 连接执行程序
· 用MS script encode加密asp(转)


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077