当前位置: 移动技术网 > IT编程>开发语言>Asp > 使用ASP实现网站的“目录树”管理的代码

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

2017年12月12日  | 移动技术网IT编程  | 我要评论
使用asp实现网站的目录树数据库结构(共使用了两个表)1。tblcategory字段名  类型   root   bina
使用asp实现网站的目录树

数据库结构(共使用了两个表)
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>
<head>
<title>javascript tree control template</title>
</head>
<frameset cols=""210,*"">
?<frame src=""tree.asp"" name=""toc"">
?<frame src=""main.htm"" name=""basefrm"">
</frameset>
</html>

4.main.htm
<head><title></title></head>
<body>
<h2>start page</h2>
</body>
</html>

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 = """" %>
<html>
<head>
<link rel=""stylesheet"" href=""ftie4style.css"">
<!-- infrastructure code for the tree -->
<script src=""ftiens4.js""></script>
<!-- execution of the code that actually builds the specific tree -->
<script>
usetextlinks = 1
<%
    do while not rs.eof
       if rs(""root"") = true then %>
            folderstree = gfld(""<%= rs(""catname"") %>"", ""<%= rs(""caturl"") %>"")
    <% else %>
            aux1 = insfld(folderstree, gfld(""<%= rs(""catname"") %>"", ""<%= rs(""caturl"") %>""))
    <% currentid = rs(""id"")
            savedid = rs(""id"")
            do while currentid = savedid and not rs.eof
                if rs(""linkname"") <> """" then %>
                    insdoc(aux1, glnk(0, ""<%= rs(""linkname"") %>"", ""<%= rs(""linkurl"") %>""))
                    <%
                end if
                rs.movenext
                if not rs.eof then currentid = rs(""id"")
             loop
         end if
        if currentid = """" then rs.movenext
    loop %>
</script>
<script>
initializedocument()
</script>
<base target=""basefrm"">
<title></title>
</head>
<body bgcolor=""white"">
</body>
</html>

 


如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网