The simplest ASP paging code

Source: Internet
Author: User

<%
Set Conn=server.createobject ("Adodb.connection")
Conn.Open ("Driver=driver do Microsoft Access (*.mdb);" uid=admin;pwd=;d bq= "&server.mappath (" 1.mdb "))
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT * FROM Student"
Rs.Open sql,conn,3
Rs.pagesize=20
If Request ("page") <> "then
Epage=cint (Request ("page")
If Epage<1 then epage=1
If Epage>rs.pagecount then Epage=rs.pagecount
Else
Epage=1
End If
Rs.absolutepage=epage
%>
<table border= "0" cellpadding= "0" cellspacing= "1" bgcolor= "#0000FF" width= "80%" align= "Center" >
<tr bgcolor= "#FFFFFF" align= "Center" >
<th><%=rs (0). Name%></th><th><%=rs (1). Name%></th><th><%=rs (2). Name %></th>
</tr>
<%
For I=0 to Rs.pagesize-1
If Rs.bof or rs.eof then exit for
%>
<tr bgcolor= "#FFFFFF" align= "Center" >
<td><%=rs (0). Value%></td><td><%=rs (1). Value%></td><td><%=rs (2). Value%></td>
</tr>
<%
Rs.movenext ()
Next
%>
</table>
<p align= "center" >
<a href= "" > Home </a>&nbsp;
<a href= "index.asp?page=<%=epage-1%>" > previous page </a>&nbsp;
<a href= "index.asp?page=<%=epage+1%>" > next page </a>&nbsp;
<a href= "index.asp?page=<%=rs.pagecount%>" > Last </a>
</p>
<p align= "Center" > now is <%=epage%> page altogether has <%=rs.pagecount%> page </p>
<%
Conn.close ()
%>

*****************************************************

The table has three fields, indicating that for student the others do not need to be changed, the pagesize can also be changed, if the record is less.

If anyone has a simpler one, please post it for everyone to study together.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.