PC6下载站

分类分类

分栏显示记录集的表格演示,并实现了分页

关注+2004-11-07作者:蓝点


<%
'打开数据库
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 
%>

      
<%
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 %>
                         
<%
'分栏主要由下面这个判断来执行的,本例是每行显示两栏
if (i mod 2) =0 then
%>
     
<%end if%>      
<%
pages = pages - 1
rs.movenext
i=i+1
loop
end if
%>
   
                     
" target="_blank">" alt="" width="100" height="100" border="0">

                          <%=rs("titleofcourtesy")&rs("firstname")%>



                     
                       
                         
                       
                     

 共<%=allpages%>页&nbsp;当前第<%= thispage %>页&nbsp;
 <% if thispage<>1 then %>
 ">首页 上页
 <% End If %>
 <% if thispage<>allpages then %>
  下页 ">末页
  <% End If %>
 


展开全部

相关文章

更多+相同厂商

热门推荐

  • 最新排行
  • 最热排行
  • 评分最高
排行榜

    点击查看更多

      点击查看更多

        点击查看更多

        说两句网友评论

          我要评论...
          取消