分页显示多张图片

<!--#include file="conn.asp"-->
<html xmlns="
http://www.w3.org/1999/xhtml">
<body>
<%
dim str,rs
str="select * from pic order by id desc"
set rs=server.CreateObject("ADODB.Recordset")
rs.open str,db,1
if not rs.bof and not rs.eof then
Dim totalPut,CurrentPage                          
rs.PageSize=16                           
rs.MoveFirst
howmanyfields=rs.Fields.Count-1 
If trim(Request("Page"))<>"" then
CurrentPage= CLng(request("Page"))
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount   '显示总页数
End If
Else
 CurrentPage= 1
End If
if rs.eof then
response.write "<p align='center'> ERROR!</p>"
else
totalPut=rs.recordcount    '显示总记录数
if CurrentPage<>1 then
  if (currentPage-1)*rs.pagesize<totalPut then
  rs.move(currentPage-1)*rs.pagesize
  dim bookmark
  bookmark=rs.bookmark     '返回书签
  end if
end if
dim t
t=rs.PageSize/4
Do While Not rs.Eof And t>0                 
t=t-1
%>
<TABLE border=0 align=center>
<tr>
 <%
    for i=1 to 4
 If Not rs.Bof And Not rs.Eof Then
 %>
  <TD><B><a href="photo_intro.asp?id=<%=rs("id")%>"><img src="<%=rs("pic")%>" width="200" height="150" border="0"/></a></B></TD>
 <%
else
exit for
end if   
rs.MoveNext   
next 
 %></tr>
</TABLE>
<%
loop
end if
dim n,k
if (totalPut mod rs.pagesize)=0 then 
n= totalPut /rs.pagesize
else 
n= totalPut / rs.pagesize+1 
end if
 %>
<P align="center" class="STYLE2">第<%=currentpage%>页     共<%=n%>页   共<%=rs.recordcount%>条纪录
  <% k=currentPage
  if k<>1 then
   response.write "[<b>"+"<a href='photo.asp?page=1'>首页</a></b>] "
   response.write "[<b>"+"<a href='photo.asp?page="+cstr(k-1)+"'>上一页</a></b>] "
  else
   Response.Write "[首页] [上一页]"
  end if
  if k<>n then
   response.write "[<b>"+"<a href='photo.asp?page="+cstr(k+1)+"'>下一页</a></b>] "
   response.write "[<b>"+"<a href='photo.asp?page="+cstr(n)+"'>尾页</a></b>] "
  else
   Response.Write "[下一页] [尾页]"
  end if
   Response.Write "[<a href='index.asp' target='_parent'>返回主页</a>]"
 %>
</P>
  <span class="STYLE2">
  <%
end if
rs.close
set rs=nothing
%>
  </span>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值