請各位幫伙解決這個分頁的問題.

glodme7758 2003-10-20 09:22:59
我做了留言欄,在顯示留言信息時,我想對這些留言進行分頁,在其中出現如下的問題:
首頁,最后一頁的內容顯示正確,上一頁和下一頁都出現同樣的錯誤,"下一頁" 顯示都第二頁后就出現錯誤,一直顯示第二頁的內容."上一頁"顯示的是第一頁的內容.
源代碼如下:請幫忙改一改!
<!-- #include file="sqlcon.asp"-->
<html>
<head>
</head>
<body>
<div align="center">
<table border="0" cellspacing=0 width="80%">
<%
sqlstr="select RQ,EMAIL,ZT,NR,XM from GUSTBOOK order by RQ DESC"
set rs=server.createobject("adodb.recordset")
rs.open sqlstr,con,3,1
%>
<%
RS.PageSize =2
if not IsEmpty(request("Topage")) then
ToPage=CInt(request("ToPage"))
if ToPage>rs.PageCount then
rs.AbsolutePage=rs.PageCount
elseif ToPage<=0 then
rs.AbsolutePage=1
else
rs.AbsolutePage=ToPage
end if
end if
intCurPage=rs.AbsolutePage
%>

<font color="#808000" size="2" face="細明體"><% Response.Write "共有"&RS.RecordCount &"條留言"%></font>
<font color="#808000" size="2" face="細明體">每頁顯示<font size="2" color="red"><%=rs.pagesize%></font><font color="#808000" size="2" face="細明體">條留言 共有</font><font color="red" size="2"><%=rs.PageCount%></font><font color=#808000 size="2">頁</font>
<%
for i =1 to rs.PageSize
if rs.eof then
exit for
end if
%>
<table border="1" cellspacing="1" width="80%">
<tr bgcolor="#b7b789">
<td width="45%"><p align="left"><font size="2" face="細明體" color=#000000>主題:<%=rs("ZT")%></font></p></td>
<td width="15%"><p align="left"><font size="2" face="細明體" color=#000000>留言人:<%=rs("XM")%></font></p></td>
<td width="30%"><p align="left"><font size="2" face="細明體" color=#000000>時間:<%=rs("RQ")%></font></p></td>
<td width="10%"><p align="right"><a href="login.asp"><img border="0" src="../../khimages/image/icon_edit_topic.gif" alt="管理員可以在此對留言進行回復!"></a>  <a href="mailto:<%=rs("EMAIL")%>"><img border="0" src="../../khimages/image/icon_email.gif"></a></p></td>
</tr>
</table>
<table width="80%" border=1 cellspacing=0 background="../khimages/bj4.jpg"> <tr>
<td width="90%"><p align="left"><font size="2" face="細明體" color=#000000><img border="0" src="../../khimages/image/down2[1].gif">
留言回復:</font><font size="2" face="細明體">
<%
else
response.write"暫無回復"
endif rs1.close setrs1=nothing
%>
</font></td></tr>
</TABLE>
<table border="0" cellspacing="0" width="80%">
<tr>
<td width="100%"><img src="../../khimages/line.gif"></td>
</tr>
</table>
<%
rs.movenext
next
%>

<table width="80%" border=0 cellspacing=0>
<tr valign="baseline" align="center">
<% if -intCurPage<>1 then %>
<td width="20%">[<a href=yijian2.asp?ToPage=<%=1%>><font size="2" color=#808080>首頁</font></a>]</td>
<td width="20%">[<a href=yijian2.asp?ToPage=<%=(-intCurPage)+1%>><font size="2" color=#808080>下一頁</font></a>]</td>

<% elseif -intCurPage<>rs.PageCount then%>
<td width="20%">[<a href=yijian2.asp?ToPage=<%=1%>><font size="2" color=#808080>首頁</font></a>]</td>
<td width="20%">[<a href=yijian2.asp?ToPage=<%=(-intCurPage)-1%>><font size="2" color=#808080>上一頁</font></a>]</td>
<td width="20%">[<a href=yijian2.asp?ToPage=<%=(-intCurPage)+1%>><font size="2" color=#808080>下一頁</font></a>]</td>
<td width="20%">[<a href=yijian2.asp?ToPage=<%=rs.PageCount%>><font size="2" color=#808080>末頁</font></a>]</td>
<% end if %>
</tr>
</table>
</div>

<%rs.close
set rs=nothing
con.close
set con=nothing
%>
...全文
24 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

28,390

社区成员

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

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