一个翻页的小问题,请高手指教。
我用一个表单调用下列程序, 能够显示出查询结果的第一页,但点“下一页”时没有反应。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件搜索</title>
</head>
<body>
<div align="left">
<html>
<title>分页技术</title>
<head>
<%
const MaxPerPage=10
dim sql
dim rs
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim page
%>
</head>
<body bgcolor=Thistle>
<!--#INCLUDE file="ADOVBS.inc"-->
<% '建立数据库的连接
word=trim(request("word"))
dim mycon,con
Set con=Server.CreateObject("ADODB.Connection")
mycon= "DRIVER=Microsoft Access Driver (*.mdb);DBQ="&Server.MapPath("/study/search.mdb")
con.open mycon
%>
<!--'建立CONNECTION对象并打开数据库
'创建Recordset对象的例程,打开Recordset对象传递SQL串以及所有的连接信息 -->
<% set rs=server.createobject("ADODB.Recordset")
rs.open "SELECT * FRoM redsearch where id or keyword or title like '%"&word&"%'",MyCon,1,3
if not(rs.eof and rs.bof) then
rs.movefirst
end if
%>
<%
rs.pagesize=MaxPerPage
howmanyfields=rs.Fields.Count-1
page=1
If trim(Request("word"))<>"" then
CurrentPage= page
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If
if rs.eof then
response.write "<p align='center'> 没有符合条件的记录!</p>"
else
totalPut=rs.recordcount
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage<totalPut then
rs.move(currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
end if
end if
dim n,k
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if%>
</FONT></FONT></P>
<%rs.movefirst%>
<P>第 <%=currentpage%> 页,共 <%=n%> 页 符合查找条件的共<%=rs.recordcount%> 条纪录
</P>
<TABLE border=1 align=center>
<tr>
<TD><div align="center"><B>文件编号</B></div></TD>
<TD><div align="center"><B>题 目</B></div></TD>
<TD><div align="center"><B>关键字</B></div></TD>
<%
for i= 0 to howmanyfields%>
<%
next
i=0
do while not rs.eof and i<maxperpage%>
<tr align=middle>
<%for j=0 to howmanyfields-1%>
<td>
<div align="left"> <a href="http://server/study/<% =rs("url") %>"> <%=rs(j)%> </a></div></td>
<%next%>
</tr>
<%
i=i+1
rs.movenext
loop
%>
</TABLE>
<% k=currentPage
if k<>1 then
response.write "<b>"+"<a href='search.asp?page=1,word="+chr(34)+word+chr(34)+"'>首页</a></b> "
response.write "<b>"+"<a href='search.asp?page="+cstr(k-1)+",word="+chr(34)+word+chr(34)+"'>上一页</a></b> "
else
Response.Write "[首页] [上一页]"
end if
if k<>n then
response.write "<b>"+"<a href='search.asp?page="+cstr(k+1)+",word="+chr(34)+word+chr(34)+"'>下一页</a></b> "
response.write "<b>"+"<a href='search.asp?page="+cstr(n)+",word="+chr(34)+word+chr(34)+"'>尾页</a></b> "
else
Response.Write "[下一页] [尾页]"
end if
Response.Write rs.recordcount
%>
<%
end if
rs.close
set rs=nothing
%>
</body>
</html>