两级菜单分别从数据库的两个表里提取数据,请问怎么做树形目录?

maweijun_z 2009-09-01 03:59:49
第一级菜单从A里提取数据 admin_hyyy_types (表名) hyyy_types_id hyyy_types_name
第二级菜单从B里提取数据 admin_hyyy (表名) hyyy_types_id hyyy_title
请问怎么做树形目录?能帮忙写个例子吗?
新手转不过弯来了,不怎么改怎么写。




<%
strsql="select * from admin_hyyy_types order by hyyy_types_id asc"
set rs=conn.execute(strsql)
if not rs.bof then
do
if rs.eof then exit do
%>

一级目录<%=rs("hyyy_types_name")%

-- 二级目录

<%
rs.movenext
loop
end if
set rs=nothing
%>


...全文
228 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
maweijun_z 2009-09-09
  • 打赏
  • 举报
回复
是浏览器缓存的问题 清下缓存就好了
maweijun_z 2009-09-01
  • 打赏
  • 举报
回复
sqls="select * from admin_hyyy where hyyy_types_id='"&rss("hyyy_types_id")&"' order by hyyy_order_id"

参数传递及关联信息这里不太明白 hyyy_types_id 这个是两个表都有的字段
maweijun_z 2009-09-01
  • 打赏
  • 举报
回复

<!--#include file="conn.asp"-->
<%
dim strFileName,MaxPerPage,ShowSmallClassType
dim totalPut,CurrentPage,TotalPages
dim BeginTime,EndTime
dim founderr, errmsg
dim BigClassName,SmallClassName,SpecialName,keyword,strField,hyyy_types_id
dim rs,sql,sqlArticle,rsArticle,sqlSearch,rsSearch,sqlBigClass,rsBigClass,sqlSpecial,rsSpecial
dim SpecialTotal
BeginTime=Timer
BigClassName=Trim(request("hyyy_types_name"))
SmallClassName=Trim(request("hyyy_title"))
SpecialName=trim(request("SpecialName"))
keyword=trim(request("keyword"))
hyyy_types_id=Trim(request("hyyy_types_id"))
if keyword<>"" then
keyword=replace(replace(replace(replace(keyword,"'","‘"),"<","<"),">",">")," "," ")
end if
strField=trim(request("Field"))

if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
sql="Select * From admin_hyyy_types where hyyy_types_id<>1 order by hyyy_types_order_id"
'response.write sql
rs.open sql,conn,1,3
'=================================================
'过程名:ShowSmallClass_Tree
'作 用:树形目录方式显示栏目
'参 数:无
'=================================================
'Sub ShowSmallClass_Tree()
%>
<html>
<head>
<title>sss</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="style1.css">

<SCRIPT language=javascript>
function opencat(cat,img){
if(cat.style.display=="none"){
cat.style.display="";
img.src="img/class2.gif";
} else {
cat.style.display="none";
img.src="img/class1.gif";
}
}
</Script>
<style type="text/css">
<!--
.style3 {font-family: Webdings; font-size: 16px; }
.style5 {font-family: Webdings; font-size: 16px; color: #FFFF00; }
-->
</style>
</head>
<body>
<TABLE width="200" border=0 align="center" cellPadding=0 cellSpacing=0 background="">
<%
dim i
' Response.Write "栏目正在建设中……"
'else
i=1
do while not rs.eof
%>
<TR bgcolor="#f2f2f2">
<TD width=8 height=24 align=center id=item$pval[catID]) style="CURSOR: hand" onMouseUp="opencat(cat10<%=i%>000, img10<%=i%>000);" language=javascript> </TD>
<TD align=center id=item$pval[catID]) style="CURSOR: hand" onMouseUp="opencat(cat10<%=i%>000, img10<%=i%>000);" language=javascript> <IMG id=img10<%=i%>000 src="img/class1.gif" width=20 height=20></TD>
<TD class='ML_Tdbg'><a href='test.asp?bigclass=<%=rs("hyyy_types_id")%>'language=javascript onMouseOver="opencat(cat10<%=i%>000, img10<%=i%>000);"><%=rs("hyyy_types_name")%></a></TD>
</TR>
<TR bgcolor="#99CCFF">
<TD id=cat10<%=i%>000 style="DISPLAY: none" colspan="3">
<%
dim rss,sqls,j
set rss = server.CreateObject ("adodb.recordset")
sqls="select * from admin_hyyy where hyyy_types_id='"&rss("hyyy_types_id")&"' order by hyyy_order_id"
rss.open sqls,conn,1,1
if rss.eof and rss.bof then
Response.Write "没有小分类"
else
j=1
do while not rss.eof
%>
   <IMG height=20 src="img/class3.gif" width=26 align=absMiddle border=0><a href="#"><%=rss("hyyy_title")%></a><BR>
<%
rss.movenext
j=j+1
loop
end if
rss.close
set rss=nothing
%>
</TD>
</TR>
<%
rs.movenext
i=i+1
loop
'end if
%>
</TABLE>

homel 2009-09-01
  • 打赏
  • 举报
回复
set rs=server.CreateObject("adodb.recordset")
sql="Select * From BigClass where bigclassid<>1"//替换成你的sql语句,是主表信息
'response.write sql
rs.open sql,conn,1,3



sqls="select * from smallclass where b_name='"&rs("BigClassName")&"'order by s_id" //替换这句换成你的细表的信息,注意参数传递及关联信息
homel 2009-09-01
  • 打赏
  • 举报
回复
<!--#include file="conn.asp"-->
<%
dim strFileName,MaxPerPage,ShowSmallClassType
dim totalPut,CurrentPage,TotalPages
dim BeginTime,EndTime
dim founderr, errmsg
dim BigClassName,SmallClassName,SpecialName,keyword,strField
dim rs,sql,sqlArticle,rsArticle,sqlSearch,rsSearch,sqlBigClass,rsBigClass,sqlSpecial,rsSpecial
dim SpecialTotal
BeginTime=Timer
BigClassName=Trim(request("BigClassName"))
SmallClassName=Trim(request("SmallClassName"))
SpecialName=trim(request("SpecialName"))
keyword=trim(request("keyword"))
if keyword<>"" then
keyword=replace(replace(replace(replace(keyword,"'","‘"),"<","<"),">",">")," "," ")
end if
strField=trim(request("Field"))

if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
sql="Select * From BigClass where bigclassid<>1"
'response.write sql
rs.open sql,conn,1,3
'=================================================
'过程名:ShowSmallClass_Tree
'作 用:树形目录方式显示栏目
'参 数:无
'=================================================
'Sub ShowSmallClass_Tree()
%>
<html>
<head>
<title>sss</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="style1.css">

<SCRIPT language=javascript>
function opencat(cat,img){
if(cat.style.display=="none"){
cat.style.display="";
img.src="img/class2.gif";
} else {
cat.style.display="none";
img.src="img/class1.gif";
}
}
</Script>
<style type="text/css">
<!--
.style3 {font-family: Webdings; font-size: 16px; }
.style5 {font-family: Webdings; font-size: 16px; color: #FFFF00; }
-->
</style>
</head>
<body>
<TABLE width="200" border=0 align="center" cellPadding=0 cellSpacing=0 background="">
<%
dim i
' Response.Write "栏目正在建设中……"
'else
i=1
do while not rs.eof
%>
<TR bgcolor="#f2f2f2">
<TD width=8 height=24 align=center id=item$pval[catID]) style="CURSOR: hand" onmouseup="opencat(cat10<%=i%>000, img10<%=i%>000);" language=javascript> </TD>
<TD align=center id=item$pval[catID]) style="CURSOR: hand" onmouseup="opencat(cat10<%=i%>000, img10<%=i%>000);" language=javascript> <IMG id=img10<%=i%>000 src="img/class1.gif" width=20 height=20></TD>
<TD class='ML_Tdbg'><a href='test.asp?bigclass=<%=rs("BigClassName")%>'language=javascript onmouseover="opencat(cat10<%=i%>000, img10<%=i%>000);"><%=rs("BigClassName")%></a></TD>
</TR>
<TR bgcolor="#99CCFF">
<TD id=cat10<%=i%>000 style="DISPLAY: none" colspan="3">
<%
dim rss,sqls,j
set rss = server.CreateObject ("adodb.recordset")
sqls="select * from smallclass where b_name='"&rs("BigClassName")&"'order by s_id"
rss.open sqls,conn,1,1
if rss.eof and rss.bof then
Response.Write "没有小分类"
else
j=1
do while not rss.eof
%>
   <IMG height=20 src="img/class3.gif" width=26 align=absMiddle border=0><a href="test.asp?bigclass=<%=rs("BigClassName")%>&smallclass=<%=rss("s_name")%>"><%=rss("s_name")%></a><BR>
<%
rss.movenext
j=j+1
loop
end if
rss.close
set rss=nothing
%>
</TD>
</TR>
<%
rs.movenext
i=i+1
loop
'end if
%>
</TABLE>
maweijun_z 2009-09-01
  • 打赏
  • 举报
回复
谁能帮我写一下这段程序 小弟感激不尽
maweijun_z 2009-09-01
  • 打赏
  • 举报
回复
我知道是有联系的,传递参数hyyy_types_id就可以,关键是不会写
homel 2009-09-01
  • 打赏
  • 举报
回复
建立2个记录集
因为你的A table 和B table是有联系的,将主表和细表关联的参数传递给细表就可以了啊?
homel 2009-09-01
  • 打赏
  • 举报
回复
hyyy_types_id?
那应该就是这个字段了
贴个数据出来看看啊

28,405

社区成员

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

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