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
%>
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.