Simple paging function A common use _ Application skills

Source: Internet
Author: User
Copy Code code as follows:

<%
Page=trim (Request ("page")
Maxperpage=40
First=true
Last=true
Dim rs
Set Rs=server. CreateObject ("Adodb.recordset")
Sql= "Select Id,title,add1,cartype,isred,enterdate,hits from Newnews where classtype=0 and Pass=1 order by id DESC"
Rs.Open sql,conn,1,1
Rs.pagesize=maxperpage
Totalpage=rs.pagecount
If Len (page) =0 Then
Intpage=1
First=false
Else
If CInt (page) <=1 Then
Intpage=1
First=false
Else
If CInt (page) >=rs.pagecount Then
Intpage=rs.pagecount
Last=false
Else
Intpage=cint (page)
End If
End If
End If
If not rs.eof then
Rs.absolutepage=intpage
End If
For A=1 to Maxperpage
If Rs.eof then exit for
%>
<tr <%if (a mod 2) =0 Then
Response.Write "Bgcolor= #ffffff"
Else
Response.Write "Bgcolor= #f6f6f6"
End If
%>>
&LT;TD height= "><div" align= "center" ><%=a%></div></td>
<td><div align= "center" >
<%add=rs ("Add1")
Substring add,4
%>
</div></td>
<td>
<a href= "displaynews.asp?id=<%=rs (" id ")%>" target= "_blank" >
<%
If RS ("isred") =true Then
%>
<font color= "Red" >
<%title=rs ("title")
Substring title,20
%></font>
<%else
Title=rs ("title")
Substring title,20
%>
<%
End If
%>
</a></td>
<td><div align= "Center" ><%=rs ("Cartype")%></div></td>
<td><div align= "center" >
<%thetime=rs ("Enterdate")
Themon=datepart ("M", Thetime)
If Len (Themon) <2 then themon= "0" &themon
Theday=datepart ("D", Thetime)
If Len (theday) <2 then theday= "0" &theday
ther=themon& "-" &theday
Response.Write Ther
%>
</div></td>
<td><div align= "Center" ><%=rs ("hits")%></div></td>
</tr>
<%
Rs.movenext
If Rs.eof then exit for
Next
%>
</table>
<table width= "100%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
&LT;TD height= "5" ></td>
</tr>
</table>
<table width= "100%" border= "0" cellpadding= "0" cellspacing= "0" >
<tr>
&LT;TD height= bgcolor= "#f6f6f6" >
<div align= "center" >
<%if Rs.pagecount>0 then%>
Total <%=rs.recordcount%> | current page <%=intpage%>/
<%

=rs.pagecount%>

<% End If%>
<%if intpage>1 then%>
<a href= "<%request. ServerVariables ("Script_name")%>?

Page=1 "> Home </a>
<%else%>
Home
<%end if%>
<%if-Then%>
<a href= "<%request. ServerVariables ("Script_name")%>?

Page=<%=intpage-1%> "> Prev </a>
<%else%>
Previous page
<%end if%>
<%if Last and Intpage<rs.pagecount then%>
<a href= "<%request. ServerVariables ("Script_name")%>?

Page=<%=intpage+1%> "> next page </a>
<%else%>
Next page
<%end if%>
<%if Intpage<rs.pagecount then%>
<a href= "<%request. ServerVariables ("Script_name")%>?

Page=<%=rs.pagecount%> "> End </a>
<%else%>
Last
<%end if%>
Go to
<select onchange= "Location=this.options

[This.selectedindex].value ">
<%for B=1 to Rs.pagecount
If B=intpage then%>
<option value= "<%request. ServerVariables ("Script_name")%>?page=<%=b%> "selected>

Page <%=b%> </option>
<% Else%>
<option value= "<%request. ServerVariables ("Script_name")%>?page=<%=b%> "> <%=b%> page

</option>
<%end if
Next%>
</select>
</div></td>
</tr>
</table>
</body>
<%
Rs.close
Set rs=nothing
Conn.close
Set conn=nothing
%>

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.