ASP article pagination

Source: Internet
Author: User

<%
Num_row=3 ' number of products placed per line
Rows=3 ' number of product lines placed
Maxpp=num_row*rows ' paging needs maxpp
Set Rs=server.createobject ("Adodb.recordset")
Sql= ' select * from Shop_books where nclassid= ' &nid& ' ORDER by adddate Desc '
Rs.Open sql,conn,1,1
If Rs.eof Then
Response. Write "No record!"
Else
Page=cint (Request ("page")
Strfilename= "Auction2.asp?lx=big&anid="
If not IsEmpty (Request ("page") Then
Currentpage=cint (Request ("page")
Else
Currentpage=1
End If
Totalput=rs.recordcount
if (currentPage-1) *maxpp>totalput Then
if (totalput mod maxpp) =0 Then
Currentpage=totalput \ MAXPP
Else
Currentpage=totalput \ maxpp + 1
End If
End If
If Currentpage=1 then (www.111cn.net)
Showcontent
ShowPage Totalput,maxpp,strfilename
Else
if (currentPage-1) *maxpp<totalput Then
Rs.move (currentPage-1) *maxpp
Showcontent
ShowPage Totalput,maxpp,strfilename
Else
Currentpage=1
Showcontent
ShowPage Totalput,maxpp,strfilename
End If
End If
End If
%>
<%sub showcontent%>
<table width= "100%" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<%
J=1 ' Initialize J, whose value is the number of products displayed on the page
Do as not (rs.eof or err) ' when there is a record
if (J MoD num_row) =1 then Response.Write "<tr>" End If ' j is incremented starting from 1, starting to show 1 lines
%>
&LT;TD width= "<%= (100/num_row)%>%" align=center> <table width=100 height=189 cellSpacing=1 Border=0>
<TBODY>
<TR>
&LT;TD align=center><%if rs ("ta") = "" Then
Response.Write "<div align=center><a href=show.asp?id=" &rs ("BookID") & "></a></div> "
Else%>
<a href=show.asp?id=<%=rs ("BookID")%> ></a>
<%end if%> </td>
</tr>
<TR>
&LT;TD height=26 bgcolor= #ffffff align=center><%
Response.Write Trim (RS ("BookName"))%></td>
</tr>
<TR>
&LT;TD height=5 bgcolor= #ffffff align=center></td>
</tr>
</tbody>

</table> </td>
<%
if (J MoD num_row) =0 then Response.Write "</tr>" End If ' when the value of J is a multiple of the Num_row a row
J=j+1
If J>maxpp then Exit Do
Rs.movenext
Loop ' round it.
%>
<!--start: The following are the number of columns that are not replenished when the record is all displayed and the number of tables is not sufficient-->
<%
Dim k
k= (j-1) mod Num_row
If not (k=0) then
Response.Write "<td colspan=" & (num_row-k) & "Width=" & (CInt (100/num_row) * (num_row-k)) & ">& Nbsp;</td> "
Response.Write "</tr>"
End If
%><!--End-->
</table>
<%end sub%>
<%
function ShowPage (totalput,maxpp,filename)
Dim n
If Totalput mod maxpp=0 then
N=totalput \ MAXPP
Else
N=totalput \ Maxpp+1
End If
Response.Write "<form method=post action=" &filename& ">"
Response.Write ""
If Currentpage<2 Then
Response.Write "First prev &nbsp;"
Else
Response.Write "<a href=" &filename& "?page=1> home </a>&nbsp;"
Response.Write "<a href=" &anclassid& "page=" &currentPage-1& "> Page </a>&nbsp;"
End If
If N-currentpage<1 Then
Response.Write "Next page &nbsp; last &nbsp;"
Else
Response.Write "<a href=" &filename& "page=" &currentPage+1& "> next page </a>&nbsp;"
Response.Write "<a href=" &filename& "page=" &n& "> Last </a>"
End If
Response.Write "" &currentPage& "/" &n& "page &nbsp;"
Response.Write "&MaxPP& Item/page"
End Function
%>

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.