I wrote the universal Paging source code, simple enough that you just need to write a SQL statement on it, Super cool!

Source: Internet
Author: User
Tags include insert
Pagination | statement | Source code This paging code is simple to use, with only 4 steps:
(1) Constructing SQL query statements, setting database connection strings, and setting the number of records displayed per page
(2) Insert the paging control code <b>navigator_init.inc</b> file
(3) in the appropriate place on the page (that is, where you want to display "top page, Next page"), insert the pager code <b>navigator.inc</b>
(4) Display the record of this page by looping



< a > ASP files that require paging

Sample.asp

<%
' Get the full path of the current ASP page, the important skill
Thescript = Request.ServerVariables ("Script_name")

' (1) Constructing SQL statements

Myconnstr = "Driver={sql server};server=yourserver;uid=sa;pwd=;d atabase=yourdatabase"
Thepagesize = 20 ' number of records displayed per page

Usql = "SELECT * FROM Yourtablename"

' (2) inserting paging control code
%>
<!--#include file= ". /inc/control/navigator_init.inc "-->

<title>test</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<link rel= "stylesheet" href= ". /default.css "type=" Text/css ">

<!--your HTML code//-->

<table width= "100%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
<td>
<!--(3) Insert pager code-->
<!--#include file= ". /inc/control/navigator.inc "-->
</td>
</tr>
</table>

<table width= "100%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
<td>
<!--(4) Display this page with a circular record-->

<% for i = 1 to rs.pagesize%>
<!--your records display code//-->
<%
Rs. MoveNext
If Rs. EOF Then
Exit for
Rs.close
Conn.close
End If
Next
%>

</td>
</tr>
</table>


</body>



< two > Paging control code:

Navigator_init.inc

<%
Thecurrentpagenum = CLng (Request ("PN")



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.