打印

[ASP在线教程] 如何使用asp实现网站的“目录树”管理

如何使用asp实现网站的“目录树”管理

使用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>
  



TOP

返回顶部
AYBlue

Processed in 0.071234 second(s), 7 queries.

当前时区 GMT+8, 现在时间是 2009-1-8 14:39 京ICP备06054220号

清除 Cookies - 联系我们 - 163K.com - Archiver - WAP