总是修改不好,麻烦各位帮忙,谢谢,关于查询到的结果翻页的问题
查询到的结果,我是每页显示10行,但查询结果有15行,点击下一页时总是不能正确显示,而是显示的全部信息,麻烦帮我改下代码吧,谢谢了
<body>
<%
bname= "questioncxok.asp "
wtnr=request( "wtnr ")
wtssh=request( "wtssh ")
wtr=request( "wtr ")
Set rs = Server.CreateObject( "ADODB.Recordset ")
sql= "select * from question WHERE 1=1 "
if request( "wtnr ") <> " " then
sql=sql & " and wtnr like '% "&wtnr& "% ' "
end if
if request( "wtssh ") <> "ok " then
sql=sql & " and wtssh like '% "&wtssh& "% ' "
end if
if request( "wtr ") <> "a " then
sql=sql & " and wtr like '% "&wtr& "% ' "
end if
sql=sql & " order by ID DESC "
rs.open sql,conn,1
if not rs.eof and not rs.bof then
rs.pagesize=10
page=request( "page ")
if not isnumeric(page) then
page=1
end if
page=clng(page)
if err.number <> 0 then
page=1
end if
if page <1 then page=1
if page> rs.pagecount then page=rs.pagecount
href= "questioncx.asp "
rs.absolutepage=page
%>
<div align= "cneter ">
<center>
<div align= "left ">
<table border= "1 " width= "723 " cellspacing= "0 " cellpadding= "0 " bordercolor= "#008000 " bordercolordark= "#FFFFFF " height= "28 " style= "word-break: break-all ">
<tr>
<td height= "1 " width= "35 " bgcolor= "#CC6600 " align= "center ">
<p align= "center "> ID </td>
<td height= "1 " width= "267 " bgcolor= "#CC6600 " align= "center "> 问题内容 </td>
<td height= "1 " width= "67 " bgcolor= "#CC6600 " align= "center "> 问题所属 </td>
<td height= "1 " width= "67 " bgcolor= "#CC6600 " align= "center "> 提问人 </td>
<td height= "1 " width= "40 " bgcolor= "#CC6600 " align= "center "> 操作 </td>
</tr>
<%
for ipage=1 to rs.pagesize
if color then
bg= "#eeeeee "
else
bg= "#ffffff "
end if
%>
<tr>
<td height= "21 " width= "35 ">
<p align= "center "> <%=RS( "id ")%> </td>
<td height= "21 " width= "267 "> <%=RS( "wtnr ")%> </td>
<td height= "21 " width= "67 ">
<p align= "center "> <%=RS( "wtssh ")%> </td>
<td height= "21 " width= "67 ">
<p align= "center "> <%=RS( "wtr ")%> </td>
<td height= "21 " width= "40 ">
<p align= "center "> <a href= " <%=bname%> ?id= <%=RS( "id ")%> "> 查询 </a> </td>
</tr>
<%
rs.movenext
color=not color
if rs.eof then exit for
next
%>
</table>
</div>
</center>
</div>
</form>
<input type= "hidden " name= "page " value= " <%=page%> ">
</form>
<div align= "left ">
<center>
<table width= "428 " >
<td width= "420 ">
<table border=0 width=334 cellspacing= "0 " cellpadding= "0 ">
<tr> <form action= <%=href%> method=get>
<td align= "left ">
<%
response.write " <a href= "&href& "?page=1> 第一页 </a> "
%>
</td>
<td align= "center ">
<%
response.write " <a href= "&href& "?page= "&(page-1)& "> 上一页 </a> "
%>
</td>
<td align= "center ">
<%
response.write " <a href= "&href& "?page= "&(page+1)& " > 下一页 </a> "
%>
</td>
<td align= "center ">
<%
response.write " <a href= "&href& "?page= "&rs.pagecount& "> 最后一页 </a> 现在是第 "&page& "页 共 "&rs.pagecount& "页 "
%>
</td>
</form> </tr> </table> </table> </center>
<br>
<%
else
%>
<br> <br> <br>
<div align= "center ">
<center>
<table border= "0 " cellpadding= "0 " cellspacing= "0 " width= "531 ">
<tr>
<td width= "426 " align= "center ">
<p align= "center "> <font size= "2 " color= "red "> 对不起,没有相关纪录 </font> </p>
</td>
<td width= "105 " align= "center ">
</td> </tr> </table>
</center>
</div>
</form>
<%
end if
rs.close
conn.close
%>
</body>
</html>
[解决办法]
还有这些参数没有传递
,所以点下一页的时候根本没有查询,显示全部
bname= "questioncxok.asp "
wtnr=request( "wtnr ")
wtssh=request( "wtssh ")
wtr=request( "wtr ")
如
response.write " <a href= "&href& "?page=1 "& "&wtnr= "&wtnr> 第一页 </a> "
[解决办法]
少了一个&
response.write " <a href= "&href& "?page= "&(page+1)& "&wtnr= "&wtnr& "&wtssh= "&wtssh& "&wtr= "&wtr& " "& " > 下一页 </a> "
再测