SoFunction
Updated on 2025-04-12

How to display database query results paging?

<%
if ("PageNumber").count > 0 then

' Specify the page number parametersPageNumber.If you specify a page number,Based on the specified page number.

PageNumber = ("PageNumber")(1)
else
PageNumber = 1

' If no page number is specified,The default is1.
end if

RecordNumberPerPage = 10

' Displayed per page10Record.

 set ARecordSet = ("")
"select * from contact1",AConnection,1
' Execute a query,NoticeOpenThe third parameter specified in the statement.

= RecordNumberPerPage

' Specify the number of records per page.
= PageNumber

' Specify the current page number.

"<br>
Each page has"&&"Record"
"<br>
There are a total of"&&"Page"
"<br>
This is the first"&PageNumber&"Page"

"<Table border=1>"
'
Display query results in table form.

"<tr>"
For FieldNo = 0 to - 1
"<td>"&ARecordSet( FieldNo ).Name&"</td>"
Next
"</tr>"
'
Show field names.

RecordCounter = 0
Do while not
RecordCounter = RecordCounter + 1
'
Show query.

if RecordCounter > RecordNumberPerPage then

' If the number of records to be displayed is greater than the number of records per page,Then stop displaying.
Exit do
end if

  "<tr>"
For FieldNo = 0 to - 1
"<td>"&ARecordSet( FieldNo )&"</td>"
Next
"</tr>"

' Show a record.

 
Loop
'
Turn to the next record.

"</Table>"

if PageNumber > 1 then

' If it's not the first page,Prompt on the previous page.
"<p><A href = ?PageNumber="&(PageNumber-1)&">[
Previous page]</a>"

[1][2] Next page