一个分页程序,到第二页的时候就会有数据重复,如何解决?
<%
sub move_prev(rs, num)
do while num > 0
rs.moveprevious
num = num - 1
loop
end sub
sub move_next(rs, num)
do while not rs.eof and num > 0
rs.movenext
num = num - 1
loop
end sub
'Variables declaration~
dim rs, sqlStr, newsPerPage, pageNo, pageTotal, i
'Build up the recordset~
set rs=server.CreateObject("adodb.recordset")
sql="select * from product where bigclass='1' order by id"
rs.open sql,conn,3,3
newsPerPage =5
if isempty(Request("page")) then
pageNo = 1
else
pageNo = Cint(Request("page"))
end if
if rs.recordcount = 0 then
pageTotal = 1
Response.Write("no")
else
if int(rs.recordcount / newsPerPage) = rs.recordcount / newsPerPage then
pageTotal = int(rs.recordcount / newsPerPage)
else
pageTotal = int(rs.recordcount / newsPerPage) + 1
end if
call move_next(rs, (pageNo - 1) * newsPerPage)
i = newsPerPage
do while not rs.eof and i>0
' j=1
%>
<tr>
<td><a href="trn.asp?id=<%=rs("id")%>"><img src="../pic/small/<%=rs("files2")%>" width=98 height=67 border=0></a></td>
<%rs.movenext%>
<td>
<%if not rs.eof then%>
<a href="trn.asp?id=<%=rs("id")%>"><img src="../pic/small/<%=rs("files2")%>" width=98 height=67 border=0></a></td>
<%
'j=j+1
' if j>1 then exit do
rs.movenext
end if
%>
</tr>
<%
i = i - 1
loop
rs.close
set rs=nothing
end if
%>
<tr>
<td colspan=2 align=center class=small>
<% 'if pageNo > 1 then %>
<div align="center"><img src="images/toleft.gif" width=8 height=8 border=0 hspace=8>
<%'end if
'if pageNo < pageTotal then
%>
<%
for i = 1 to pageTotal
Response.Write("<font color='#FF0000'><a href='?page=" & i & "'>" & i & "</a></font> ")
next
'end if
%><img src="images/toright.gif" width=8 height=8 border=0 hspace=8>
</div></td>