<!-- 本示例演示一个通用的记录集分栏显示,因为有的时候显示产品等要每行显示若干个,而不是每行显示一个。如有有这种分栏显示的表格,直接把下面的代码套进去就行了,本示例是每行显示2个记录,再最下面还显示了分页栏。 -->
<%
'打开数据库
Set conn = Server.CreateObject("ADODB.Connection")
strconn="Driver={sql server};server=localhost;database=northwind;uid=sa;pwd=sa;"
conn.Open strconn
'获取本页地址
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
fileName = Mid(fileName,postion)
'打开记录集www.knowsky.com
set rs=server.CreateObject("adodb.recordset")
rs.open "select titleofcourtesy,firstname,photopath from Employees order by employeeid desc",conn,1,1
%>
<!-- 产品展示表格 -->
<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="&
<%
'打开数据库
Set conn = Server.CreateObject("ADODB.Connection")
strconn="Driver={sql server};server=localhost;database=northwind;uid=sa;pwd=sa;"
conn.Open strconn
'获取本页地址
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
fileName = Mid(fileName,postion)
'打开记录集www.knowsky.com
set rs=server.CreateObject("adodb.recordset")
rs.open "select titleofcourtesy,firstname,photopath from Employees order by employeeid desc",conn,1,1
%>
<!-- 产品展示表格 -->
<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="&
| 对此文章发表了评论 |
