供有2个asp文件
第一个是用来显示图书目录 ml.asp
详细代码如下:
<%@ Language=VBScript %>
<% Dim connstr
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("tushu.mdb")
Set szczf=Server.CreateObject("ADODB.Connection")
szczf.Open connstr
%>
<%
exec="SELECT * FROM tushumulu"
set rs=server.CreateObject("adodb.recordset")
rs.open exec,szczf,1,1
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>图书目录</title>
</head>
<% Dim connstr
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("tushu.mdb")
Set szczf=Server.CreateObject("ADODB.Connection")
szczf.Open connstr
%>
<%
exec="SELECT * FROM tushumulu"
set rs=server.CreateObject("adodb.recordset")
rs.open exec,szczf,1,1
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>图书目录</title>
</head>
<body>
<%
if rs.eof and rs.bof then
response.Write("暂时没有书籍")
else
for i=1 to 7 由于数据库是在后台添加内容的,所以知道内容不会超过7条.
if not rs.eof then
%>
<a href="xx.asp?bh=<%=rs("bh")%>"><%=rs("mc")%></a>
<%
if rs.eof and rs.bof then
response.Write("暂时没有书籍")
else
for i=1 to 7 由于数据库是在后台添加内容的,所以知道内容不会超过7条.
if not rs.eof then
%>
<a href="xx.asp?bh=<%=rs("bh")%>"><%=rs("mc")%></a>
用于调出图书名称 并且使用编号制作连接到详细的图书明细页面上.
<% rs.MoveNext
end if
next
end if%>
</body>
</html>
end if
next
end if%>
</body>
</html>
第二个是用来点击图书目录后出现详细的内容 xx.asp
代码如下:
<%@ Language=VBScript %>
<% Dim bhx
bhx="1"
if (request("bh")<>"") then 设定一个变量,使目录页上获取的BH值传给它.
bhx=request("bh")
End if
%>
<% Dim connstr
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("tushu.mdb")
Set szczf=Server.CreateObject("ADODB.Connection")
szczf.Open connstr
%>
<%
exec="SELECT * FROM tushumulu WHERE bh =" + bhx
set rs=server.CreateObject("adodb.recordset")
rs.open exec,szczf,1,1
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>明细页面</title>
</head>
<% Dim bhx
bhx="1"
if (request("bh")<>"") then 设定一个变量,使目录页上获取的BH值传给它.
bhx=request("bh")
End if
%>
<% Dim connstr
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("tushu.mdb")
Set szczf=Server.CreateObject("ADODB.Connection")
szczf.Open connstr
%>
<%
exec="SELECT * FROM tushumulu WHERE bh =" + bhx
set rs=server.CreateObject("adodb.recordset")
rs.open exec,szczf,1,1
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>明细页面</title>
</head>
<body>
<table align="center" border="1">
<tr>
<td align="left" width="25%">编号 </td>
<td align="left" width="25%">名称 </td>
<td align="left" width="25%">价格 </td>
<td align="left" width="25%">类型 </td>
</tr>
<%
While (Not rs.Eof)
%>
<tr>
<td align="left" width="25%"><%=rs("bh")%></td>
<td align="left" width="25%"><%=rs("mc")%></td>
<td align="left" width="25%"><%=rs("jg")%></td>
<td align="left" width="25%"><%=rs("zz")%></td>
</tr>
<% rs.MoveNext()
Wend
%>
</table>
<table align="center" border="1">
<tr>
<td align="left" width="25%">编号 </td>
<td align="left" width="25%">名称 </td>
<td align="left" width="25%">价格 </td>
<td align="left" width="25%">类型 </td>
</tr>
<%
While (Not rs.Eof)
%>
<tr>
<td align="left" width="25%"><%=rs("bh")%></td>
<td align="left" width="25%"><%=rs("mc")%></td>
<td align="left" width="25%"><%=rs("jg")%></td>
<td align="left" width="25%"><%=rs("zz")%></td>
</tr>
<% rs.MoveNext()
Wend
%>
</table>
</body>
<%
rs.close() 清空
Set rs=Nothing
%>
</html>
<%
rs.close() 清空
Set rs=Nothing
%>
</html>
