User choose number records to display per page
I am trying let the user be able to change the number of records to display per page using a HTML form. The problem I am having with this is that it doesn't work it seems to display all the records. Sorry i am quite new to ASP and scrypting. here is the code I used for the form:
<form action="d60Allpage.asp" method="post">
Pictures per page(the more pictures the longer to load):
<input type="text" name="NumberOfPict" value="20">
<input type="submit">
</form>
d60Allpage.asp
<%
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdText = &H0001
Dim CONN_STRING
CONN_STRING = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("d60.mdb")
Dim iPageSize
Dim iPageCount
Dim iPageCurrent
Dim strOrderBy
Dim strSQL
Dim objPagingConn
Dim objPagingRS
Dim iRecordsShown
Dim iFieldCount
Dim iRecordCount
Dim LoopRecordCount
Dim pageNum
Dim counter
Dim markShowPage
Dim I, J
iPageSize = Request.Form("NumberOfPict")
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
strSQL = "SELECT tblgeneral.dir FROM [tblgeneral] ORDER BY tblgeneral.dateTaken"
Set objPagingConn = Server.CreateObject("ADODB.Connection")
objPagingConn.Open CONN_STRING
Set objPagingRS = Server.CreateObject("ADODB.Recordset")
objPagingRS.PageSize = iPageSize
objPagingRS.CacheSize = iPageSize
objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly, adCmdText
iPageCount = objPagingRS.PageCount
iFieldCount = objPagingRS.Fields.Count
iRecordCount = objPagingRS.RecordCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If iPageCount = 0 Then
Response.Write "No records found!"
Else
objPagingRS.AbsolutePage = iPageCurrent
Dim arrDBData
ReDim arrDBData(iFieldCount, iRecordCount)
LoopRecordCount = 0
'arrDBData = objPagingRS.GetRows()
Do While LoopRecordCount < iPageSize And Not objPagingRS.EOF
For I = 0 To objPagingRS.Fields.Count - 1
arrDBData(I, LoopRecordCount) = objPagingRS.Fields(I)
Next
LoopRecordCount = LoopRecordCount + 1
objPagingRS.MoveNext
Loop
objPagingRS.Close
Set objPagingRS = Nothing
objPagingConn.Close
Set objPagingConn = Nothing
End If
iRecordCount = iRecordCount - 1
iFieldCount = iFieldCount - 1
LoopRecordCount = LoopRecordCount - 1
pageNum = Round(iRecordCount/iPageSize)
If pageNum < (iRecordCount/iPageSize) Then pageNum = pageNum + 1
Response.Write " <b> "
'For counter = 1 To pageNum
' if counter=iPageCurrent then
' Response.Write " <span class=activepage> "
' Response.Write counter
' Response.Write " </span>"
' markShowPage=1
' else
' Response.Write " <a onclick=exitoff() href=d60allpage.asp?page="
' Response.Write counter
' Response.Write " class=listingLink>"
' Response.Write counter
' Response.Write "</a>"
' end if
'
'Next
Response.Write "</b>"
Response.Write " "
Response.Write "<b>"
Response.Write "<a href=d60allpage.asp?page="
If iPageCurrent = 1 Then
Response.Write pageNum
else
Response.Write iPageCurrent-1
end if
Response.Write " class=listingLink>Back</a> "
Response.Write "<a href=d60allpage.asp?page="
If iPageCurrent = pageNum Then
Response.Write "1"
else
Response.Write iPageCurrent+1
end if
Response.Write " class=listingLink>Next</a>"
Response.Write "</b>"
%>
<p>
<table border="1">
<%
For I = 0 To LoopRecordCount
For J = 0 To ifieldCount
Response.Write "<a href=" & arrDBData(J, I) & "><img src=" & arrDBData(J, I) & " alt=" & arrDBData(J, I) & " height=133 width=200></img></a>"
Next ' J
Next ' I
%>
</table>
<%
Response.Write "</b>"
Response.Write " "
Response.Write "<b>"
Response.Write "<a href=d60allpage.asp?page="
If iPageCurrent = 1 Then
Response.Write pageNum
else
Response.Write iPageCurrent-1
end if
Response.Write " class=listingLink>Back</a> "
Response.Write "<a href=d60allpage.asp?page="
If iPageCurrent = pageNum Then
Response.Write "1"
else
Response.Write iPageCurrent+1
end if
Response.Write " class=listingLink>Next</a>"
Response.Write "</b>"
%>
Thanks in advance,
Jeff
|