分栏显示记录集的表格演示,并实现了分页
时间:2009-06-24 17:04:30
作者:互联网
<%
'打开数据库
Set conn = Se***r.CreateObject("AD***.Connection")
strconn="Driver={sql server};server=localhost;database=northwind;uid=sa;pwd=sa;"
co***Open strconn
'获取本页地址
Dim fileName,postion
fileName = Re***st.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
fileName = Mid(fileName,postion)
'打开记录集www.downcodes.com
set rs***rver.CreateObject("ad***.recordset")
rs.open "select titleofcourtesy,firstname,photopath from Employees order by employeeid desc",conn,1,1
%>
<%
if not(rs.bof and rs.eof) then
pages=4
rs***gesize=pages
if not isempty(Re***st.QueryString("page")) then
thispage=clng(Re***st.QueryString("page"))
else
thispage=1
end if
rs***nt=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=rscountpages
else
thispage=rscountpages+1
end if
end if
if(rscount mod pages)=0 then
allpages=rscountpages
else
allpages=rscountpages+1
end if
rs***solutepage=thispage
i=1
%>
<%do while not rs.eof and pages>0 %>
" target="_blank">" alt="" width="100" height="100" border="0">
https://images.downcodes.com<%=rs("titleofcourtesy")&rs("firstname")%> |
<%
'分栏主要由下面这个判断来执行的,本例是每行显示两栏
if (i mod 2) =0 then
%>
<%end if%>
<%
pages = pages - 1
rs***venext
i=i+1
loop
end if
%>
|
共<%=allpages%>页 当前第<%= thispage %>页 <% if thispage<>1 then %> ">首页 ">上页 <% End If %> <% if thispage<>allpages then %> ">下页 ">末页 <% End If %> |