专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »Asp教程 » asp读取数据库:asp简单的树形菜单从数据库读取类别 »正文

asp读取数据库:asp简单的树形菜单从数据库读取类别

来源: 发布时间:星期四, 2008年9月25日 浏览:140次 评论:0
这种做法是把所有的数据都装载到数据集中,之后利用样式显示/隐藏来显示。没有什么效率可言,只是实现了树形菜单的这种效果。我的数据库的类别是分3个表来保存的。

<%@LANGUAGE=\"VBSCRIPT\"CODEPAGE=\"936\"%>
<!--#includefile=\"../../include/conn.asp\"-->
<!DOCTYPEHTMLPUBLIC\"-//W3C//DTDHTML4.01Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head>
<metahttp-equiv=\"Content-Type\"content=\"text/html;charset=gb2312\">
<title>无标题文档</title>
<METAname=\"description\"content=\"对公司的简单描述\">
<METAname=\"keywords\"content=\"公司的主要产品类别和性质,不大于7个词,用“,”隔开\">
<linkrel=\"stylesheet\"href=\"common/style/install_style.css\"type=\"text/css\">
</head>

<body>
<scriptlanguage=\"javascript\">
functiondisplay(items)
{
varaa=document.getElementById(items);

if(aa.style.display==\"none\"){
aa.style.display=\"\";
}
else{
aa.style.display=\"none\";
}
}
</script>

<tablewidth=\"100%\"id=\"Class1\">
<%
setrsClass1=server.createobject(\"adodb.recordset\")
sqlClass1=\"select*fromcoProductFirstClass\"
rsClass1.opensqlClass1,conn,1,3
dowhilenotrsClass1.eof
%>
<tronclick=\"display(’Class2’);\">
<tdcolspan=\"2\">+<%=rsClass1(\"FirstClassName\")%></td>
<tr>
<tdwidth=\"1%\">&nbsp;</td>
<tdwidth=\"99%\">
<tablewidth=\"100%\"id=\"Class2\"style=\"display:none\">
<%
setrsClass2=server.createobject(\"adodb.recordset\")
sqlClass2=\"select*fromcoProductSecondClasswhereFirstClassID=\"&rsClass1(\"FirstClassID\")&\"\"
rsClass2.opensqlClass2,conn,1,3
dowhilenotrsClass2.eof
%>
<tronclick=\"display(’Class3’);\">
<tdcolspan=\"2\">><ahref=\"particular.asp?classid=<%=rsClass2(\"SecondClassId\")%>\"><%=rsClass2(\"SecondClassName\")%></a></td>
</tr>
<tr>
<tdwidth=\"1%\">&nbsp;</td> [Page]
<tdwidth=\"99%\">
<tablewidth=\"100%\"id=\"Class3\"style=\"display:none\">
<%
setrsClass3=server.createobject(\"adodb.recordset\")
sqlClass3=\"select*fromcoProductThirdClasswhereSecondClassID=\"&rsClass2(\"SecondClassID\")&\"\"
rsClass3.opensqlClass3,conn,1,3
dowhilenotrsClass3.eof
%>
<tr>
<td>>><%=rsClass3(\"ThirdClassName\")%></td>
</tr>
<%
rsClass3.movenext
loop
%>
</table></td>
</tr>
<%
rsClass2.movenext
loop
%>
</table>

</td>
</tr>
<tr><tdcolspan=\"2\"></tr>
<%
rsClass1.movenext
loop
%>
</table>
<%callcloseconn()%>
</body>
</html>
0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: