分页显示多张图片

来源:互联网 发布:linux yum jdk1.7 编辑:程序博客网 时间:2024/04/28 08:36

<!--#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>

原创粉丝点击