我在使用asp尋呼時遇到了一些麻煩。它能夠在每個頁面上顯示6條記錄。但是,當我轉到第二頁時,它會在每個不同的頁面上顯示相同的6條記錄。 以下是我的代碼。有什麼建議麼?在傳統ASP中尋呼
Dim iPageSize,iPageCount , iPageCurrent , strOrderBy,strSQL,iRecordsShown,I
iPageSize = 6
set registerRS=server.CreateObject("ADODB.recordset")
registerRS.PageSize = iPageSize
' Retrieve page to show or default to 1
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
qry="SELECT * FROM "dbo.CustomerOrders;"
registerRS.CacheSize = iPageSize
registerRS.open qry,ObjConn,3
iPageCount = registerRS.PageCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If iPageCount = 0 Then
Response.Write "No records found!"
Else
registerRS.AbsolutePage = iPageCurrent
end if
%>
<p>
<font size="+1">Page <strong><%= iPageCurrent %></strong>
of <strong><%= iPageCount %></strong></font>
</p>
<%
x=registerRS.recordcount
if registerRS.recordcount > 0 Then
registerRS.movefirst
End If
Do While iRecordsShown < iPageSize And Not registerRS.EOF
counter=counter+1
if counter=41 then
counter=0
counter=counter+1
end if
r = r + 1
If r = 1 then
Response.write "<tr>"
End if
%>
<td>
<%=registerRS.Fields("Address")%> <br />>
</td>
<%
If r = 2 then
Response.write "</tr>"
End if
If r = 3 then r = 1
' Increment the number of records we've shown
iRecordsShown = iRecordsShown + 1
registerRS.movenext
loop
%>
</table>
<table width=90%>
<tr>
<td>
<%
If iPageCurrent > 1 Then
%>
<a href="add.asp?page=<%= iPageCurrent - 1 %>&SchoolId=<%=registerRS.Fields("Add")%>">[<< Prev]</a>
<%
End If
' You can also show page numbers:
For I = 1 To iPageCount
If I = iPageCurrent Then
%>
<%= I %>
<%Else%>
<a href="add.asp?page=<%= I %>&SchoolId=<%=registerRS.Fields("Add")%>"><%= I %></a>
<%
End If
Next 'I
If iPageCurrent < iPageCount Then
%>
<a href="add.asp?page=<%= iPageCurrent + 1 %>&SchoolId=<%=registerRS.Fields("Add")%>">[Next >>]</a>
<%
registerRS.close
set registerRS=nothing
End If
end sub
%>
老實說,我甚至無法弄清楚你的代碼在哪裏,你認爲你是「分頁」。分頁意味着URL中有一個參數可確定要顯示哪個頁面,並根據該參數的值顯示不同的記錄。 –
這比PHP更糟糕...... –