请哪位高手帮我看一下我这个前十页后十页的分页程错在哪里?

look4sword 2004-01-18 05:34:35
现在的情况是,我每20条作一页,但现在显示的是:
第一页显示全部内容,第二页减掉20个,第三页又减掉20,这样的显示,而不是20个一页了.请高手指点!
实例请在这里
http://wind-love.com/newbbs/main.asp?bid=1_50&sid=1_50_15

程序是这样的:

<%
MMaxPerPage=20
rs.PageSize=MMaxPerPage
if trim(request("Page"))<>"" then
CurrentPage=CInt(request("Page"))
if CurrentPage>rs.PageCount then
CurrentPage=rs.PageCount
end if
else
CurrentPage=1
end if

if rs.EOF then
Response.Write "<center><font color=red>还没有贴子!</font>"
else
ttotalPut=rs.RecordCount
if CurrentPage<>1 then
if (CurrentPage-1)*MMaxPerPage<ttotalPut then
rs.Move(CurrentPage-1)*MMaxPerPage
bookmark=rs.Bookmark
end if
end if
end if


if (ttotalPut mod MMaxPerPage)=0 then
mm=ttotalPut\MMaxPerPage
else
mm=ttotalPut\MMaxPerPage+1
end if


if (ttotalPut mod (MMaxPerPage*10))=0 then
nn=ttotalPut\(MMaxPerPage*10)
else
nn=ttotalPut\(MMaxPerPage*10)+1
end if
%>


<%
if (CurrentPage mod 10)=0 then
kk=CurrentPage\10-1
else
kk=CurrentPage\10
end if

if nn>1 and CurrentPage>10 then
Response.Write "<b><a href='main.asp?bid="&request("bid")&"&sid="&request("sid")&"&page="+CStr((kk-1)*10+1)+"'>Previous</a></b>"
end if


for ii=1 to 10
jj=kk*10+ii
if jj<=mm then
if jj=CurrentPage then
Response.Write " <font color=red>"+CStr(jj)+"</font>"
else
Response.Write " <b>"+"<a href='main.asp?page="+CStr(jj)+"'>"+CStr(jj)+"</a></b>"
end if
end if
next

Response.Write " "
if kk<nn-1 then
Response.Write " <b>"+"<a href='main.asp?page="+CStr((kk+1)*10+1)+"'>Next</a></b>"
end if

k=0
for y=(page-1)*20+1 to (page-1)*20+20
do while not rs.EOF
if i mod 2 then
%>

<table width=98% border="0" height=20 cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td>内容</td>
</tr>
</table>
<%else%>
<table width=98% bgcolor=#DEE3F7 height=20 border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td>内容</td>
</tr></table>
<%end if
i=i+1
rs.MoveNext
loop
next
%>
...全文
33 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
look4sword 2004-01-19
  • 打赏
  • 举报
回复
真是多谢各位了,因为我刚学习ASP,这个程序也是在论坛上看到的.
我再研究一下.多谢了!
zhongmao 2004-01-18
  • 打赏
  • 举报
回复
请使用下面的循环来读取记录
dim intLoop
intLoop = 0

while not rs.EOF and intLoop < MMaxPerPage
.....
intLoop = intLoop + 1
rs.movenext
wend
mtide 2004-01-18
  • 打赏
  • 举报
回复
重新看了你循环这部分,更正一下

第一个错的地方是,你的Y循环的作用是什么??

第二个错的地方是,你用错了循环条件
do while not rs.Eof
这里你没有限制显示记录的数量,应该改为
do while not rs.Eof and i < MMaxPerPage

采用这种办法分页不好,你可以在论坛里看看人家的分页是怎么写的
mtide 2004-01-18
  • 打赏
  • 举报
回复
你的程序好象写的很罗嗦

好象少了一句rs.AbsolutePage = currenPage
TrueAndFalse 2004-01-18
  • 打赏
  • 举报
回复
UP

28,407

社区成员

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

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