The following paragraph is the basic paging code:
<% sql = "select………………………… omit the sql statement Set rs=Server.Createobject("ADODB.RECORDSET") rs.Open sql, conn, 1, 1 if not rs.eof then pages = 30 'Define the number of records displayed per page rs.pageSize = pages 'Define the number of records displayed per page allPages = rs.pageCount' Calculate how many pages can be divided in total page = Request.QueryString("page")'The number of pages passed through the browser' if statement belongs to the basic troubleshooting process if isEmpty(page) or Cint(page) < 1 then page = 1 elseif Cint(page) > allPages then page = allPages end if rs.AbsolutePage = page Do while not rs.eof and pages > 0 %> The content you want is output here…………… <% pages = pages - 1 rs.MoveNext Loop else Response.Write("There is no content in the database!") End if rs.Close Set rs = Nothing %>The system has already paginated the data. Let’s take a look at the definition of the pagination function that is discussed this time.
<% SUB pageUrl(pUrl) Dim eUrl txts = Request.ServerVariables("URL") txts = left(txts,instrrev(txts,"/",len(txts))-1) eUrl = "http://"; & Request.ServerVariables("server_name") & txts For i =1 to allpages txt = "" txt = "<strong>" txt = txt & "<a href=" & eUrl & pUrl & "page="&i & ">" if i = Cint(Page) then txt = txt & "<font color='bb0000'>" txt = txt & (i) if i = Cint(Page) then txt = txt & "</font>" txt = txt & "</a> ∥ </strong>" Response.Write(txt) Next END sub %>Save the above pagination function code COPY into an ASP file. Use include to introduce it in the page you need to use to call it whenever Call("/The file name you called?") is OK. For example, if you want to call it in my news page, it is <%Call("/news.asp?")%>
What we just saw is limited, which means that in the first piece of code, except for the SQL query content and output content, the other variables that declare the record set cannot be changed, otherwise they will not be able to run. In fact, this program is irrelevant. The most important thing is that this pagination function can be called in any asp leaf.