Frog frog recommendation: displays the table demonstration of the record set in different columns, and implements paging.

Source: Internet
Author: User
<! -- This example shows a general record set Column Display, because sometimes the product and so on need to display several records in each line, rather than one in each line. If a table is displayed in this column, you can simply set the following code. In this example, two records are displayed in each row, and the paging column is shown at the bottom. -->
<%
'Open the database
Set conn = server. Createobject ("ADODB. Connection ")
Strconn = "driver = {SQL Server}; server = localhost; database = northwind; uid = sa; Pwd = sa ;"
Conn. Open strconn
'Get the address of this page
Dim filename, postion
Filename = request. servervariables ("script_name ")
Postion = Limit Rev (filename, "/") + 1
Filename = mid (filename, postion)
'Open record set
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open "select titleofcourtesy, firstname, photopath from employees order by employeeid DESC", Conn, 1, 1
%>
<! -- Product display table -->
<Table width = "90%" Height = "300" border = "0" align = "center">
<%
If not (Rs. bof and Rs. EOF) then
Pages = 4
Rs. pagesize = pages
If not isempty (request. querystring ("page") then
Thispage = clng (request. querystring ("page "))
Else
Thispage = 1
End if
Rscount = Rs. recordcount
If thispage = "" Then thispage = 1
If thispage <1 then thispage = 1
If (thispage-1) * pages> rscount then
If (rscount mod pages) = 0 then
Thispage = rscount/pages
Else
Thispage = rscount/pages + 1
End if
End if
If (rscount mod pages) = 0 then
Allpages = rscount/pages
Else
Allpages = rscount/pages + 1
End if
Rs. absolutepage = thispage
I = 1
%>
<Tr>
<% Do while not Rs. EOF and pages> 0%>
<TD valign = "TOP"> <a href = "<% = RS (" photopath ") %> "target =" _ blank "> "alt =" "width =" 100 "Height =" 100 "border =" 0 "> </a> <br>
<% = RS ("titleofcourtesy") & RS ("firstname") %> </TD>
<%
'Column sharding mainly depends on the following judgment. In this example, two columns are displayed in each row.
If (I mod 2) = 0 then
%>
</Tr> <tr>
<% End if %>
<%
Pages = pages-1
Rs. movenext
I = I + 1
Loop
End if
%>

</Table>
<! --/Product display table -->
<! -- Product pagination table -->
<Table width = "90%" border = "0" align = "center">
<Tr>
<TD> <center>
Total <% = allpages %> pages & nbsp; current page <% = thispage %> & nbsp;
<% If thispage <> 1 then %>
<A href = "<% = filename &"? Page = 1 "%>"> homepage </a> <a href = "<% = filename &"? Page = "& (thispage-1) %>"> previous page </a>
<% End if %>
<% If thispage <> allpages then %>
<A href = "<% = filename &"? Page = "& (thispage + 1) %>"> next page </a> <a href = "<% = filename &"? Page = "& allpages &" "%>"> last page </a>
<% End if %>
</Center> </TD>
</Tr>
</Table>
<! --/Product paging table -->

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.