<%
'打开
数据库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.comset rs=server.CreateObject("adodb.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.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
%>
<%do while not rs.eof and pages>0 %>
" target="_blank"> " alt="" width="100" height="100" border="0">
<%=rs("titleofcourtesy")&rs("firstname")%> |
<%
'分栏主要由下面这个判断来执行的,本例是每行显示两栏
if (i mod 2) =0 then
%>
<%end if%>
<%
pages = pages - 1
rs.movenext
i=i+1
loop
end if
%>
|
共<%=allpages%>页 当前第<%= thispage %>页 <% if thispage<>1 then %> ">首页 ">上页 <% End If %> <% if thispage<>allpages then %> ">下页 ">末页 <% End If %> |