ASP modular Paging

Source: Internet
Author: User

Modular Paging

1. query statement Blocks

<%
Get the current file name
Temp = Split (request. servervariables ("url "),"/")
FY = temp (ubound (temp ))
Set rs = server. Createobject ("ADODB. recordset ")
If not isempty (Request ("page") then
Pagecount = CINT (Request ("page "))
Else
Pagecount = 1
End if
SQL = "SELECT query statement"
Rs. Open SQL, Conn, 1, 1
Rs. pagesize = 10 page records
If pagecount> Rs. pagecount or pagecount <= 0 then
Pagecount = 1
End if
If Rs. EOF and Rs. bof then %>

<Div align = "center" class = "001"> <br>
Sorry, no matching record exists! <Br>
</Div>

2. Display record Blocks

<%
Else
Rs. absolutepage = pagecount
Do while not Rs. EOF %>

Displayed records

<% I = I + 2
Rs. movenext
If I> = Rs. pagesize then exit do
Loop
%>

3.
Paging Effect
<Table width = "778" border = "0" align = "center" cellpadding = "0" cellspacing = "0">
<Tr align = "center">
<% If Rs. pagecount = 1 then %>
<TD Height = "35" colspan = "4" class = 001> <font color = "#000000"> total [<font color = "# ff0000"> <% = rs. recordcount %> </font>] <font color = "red"> 1 ~ <% = Rs. recordcount %> </font> </TD>
</Tr>
<Tr>
<% Else %>
<TD width = "19%" Height = "35" align = "center" valign = "Middle" class = 001> <font color = "#000000">
<% Page_start = (pagecount-1) * Rs. pagesize
If pagecount = 1 then page_start = 1
Page_end = Rs. pagesize * pagecount
If pagecount * Rs. pagesize => Rs. recordcount then page_end = Rs. recordcount end if %>
Total [<font color = "# ff0000"> <% = Rs. recordcount %> </font>] Information </font> </TD>
<TD width = "58%" Height = "30" align = "center" class = "fy"> <font color = "#000000">
<%
If pagecount> 5 and pagecount <Rs. PageCount-5 and Rs. pagecount> 10 then
Qizu = pagecount-4
Min = pagecount + 5
Response. Write "<a href =" & Source &"? Page = 1 & sortid = "& sortid &" & typeid = "& typeid &" & qylb = "& qylb &" & Title = "& Title &" & cityid = "& cityid & "> <font color = 'must be'> homepage </font> </a> & nbsp;"
Response. Write "<a href =" & Source &"? Page = "+ CSTR (pagecount-1) + "& sortid =" & sortid & "& typeid =" & typeid & "& qylb =" & qylb & "& Title =" & Title & "& cityid =" & cityid & "> <font color = 'must be'> previous page </font> </a> & nbsp;"
For ipage = qizu to Min
If ipage <> pagecount then
Response. Write "<a href =" & Source &"? Page = "+ CSTR (ipage) + "& sortid =" & sortid & "& typeid =" & typeid & "& qylb =" & qylb & "& cityid =" & cityid & "> <font color =' must be '> "+ CSTR (ipage) + "</font> </a> & nbsp ;"
Else
Response. Write "<font color = '# ff0000'>" & ipage & "</font>"
End if
Next
Response. Write "<a href =" & Source &"? Page = "+ CSTR (pagecount + 1) + "& sortid =" & sortid & "& typeid =" & typeid & "& qylb =" & qylb & "& Title =" & Title & "& cityid =" & cityid & "> <font color = 'must be'> next page </font> </a> & nbsp;"
Response. Write "<a href =" & Source &"? Page = "+ CSTR (RS. pagecount) + "& sortid =" & sortid & "& typeid =" & typeid & "& qylb =" & qylb & "& Title =" & Title & "& cityid =" & cityid & "> <font color = 'must be'> last page </font> </a>"
End if
If Rs. pagecount <11 then
For ipage = 1 to Rs. pagecount
If ipage <> pagecount then
Response. Write "<a href =" & Source &"? Page = "+ CSTR (ipage) + "& sortid =" & sortid & "& typeid =" & typeid & "& qylb =" & qylb & "& cityid =" & cityid & "> <font color =' must be '> "+ CSTR (ipage) + "</font> </a> & nbsp ;"
Else
Response. Write "<font color = '# ff0000'>" & ipage & "</font>"
End if
Next
End if
If pagecount <6 and Rs. pagecount> 10 then
For ipage = 1 to 10
If ipage <> pagecount then
Response. Write "<a href =" & Source &"? Page = "+ CSTR (ipage) + "& sortid =" & sortid & "& typeid =" & typeid & "& qylb =" & qylb & "& cityid =" & cityid & "> <font color =' must be '> "+ CSTR (ipage) + "</font> </a> & nbsp ;"
Else
Response. Write "<font color = '# ff0000'>" & ipage & "</font>"
End if
Next
Response. Write "<a href =" & Source &"? Page = "+ CSTR (RS. pagecount) + "& sortid =" & sortid & "& typeid =" & typeid & "& qylb =" & qylb & "& Title =" & Title & "& cityid =" & cityid & "> <font color = 'must be'> last page </font> </a>"
End if
If pagecount> Rs. PageCount-6 and Rs. pagecount> 10 then
Response. Write "<a href =" & Source &"? Page = 1 & sortid = "& sortid &" & typeid = "& typeid &" & qylb = "& qylb &" & Title = "& Title &" & cityid = "& cityid & "> <font color = 'must be'> homepage </font> </a> & nbsp;"
For ipage = Rs. PageCount-9 to Rs. pagecount
If ipage <> pagecount then
Response. Write "<a href =" & Source &"? Page = "+ CSTR (ipage) + "& sortid =" & sortid & "& typeid =" & typeid & "& qylb =" & qylb & "& cityid =" & cityid & "> <font color =' must be '> "+ CSTR (ipage) + "</font> </a> & nbsp ;"
Else
Response. Write "<font color = '# ff0000'>" & ipage & "</font>"
End if
Next
End if
%>
</Font> </TD> <form name = go2to form method = post action = <% = FY %>
<TD width = "13%" align = "center" valign = "Middle" class = "fy">
<Input type = 'siden' name = 'sortid' value = "<% = sortid %>"> <input type = 'siden' name = 'typeid' value = "<% = typeid %> "> <input type = 'den den 'name = 'qylb' value =" <% = qylb %> "> <input type = 'den den' name = 'title 'value = "<% title %>"> <input type = 'den den 'name = 'cityid' value = "<% = cityid %>"> <font color = '100 '> go to the <input type = 'text' name = 'page' size = 2 maxlength = 3>
Page </font>
</TD>
<TD width = "10%" align = "center" valign = "Middle" class = "fy"> <input name = "image" type = 'image' onclick = check () value = 'confirm 'src = '.. /images/button_h.jpg '> </TD>
</Form>
<Tr>
<TD Height = "20" colspan = "6" valign = "bottom"> <font color = "#000000"> & nbsp; </font> </TD>
</Tr>
<% End if %>
<% End if %>
</Table>

Related Article

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.