帮写个循环+分页
最有总是有朋友说我给的分少,因为是没有多少分了,所以害怕不能再发问了
所以只能少给些分了呀
写一个这样的循环(三行四列)
图片1 图片1 图片1 图片1
说明1 说明1 说明1 说明1
图片1 图片1 图片1 图片1
说明1 说明1 说明1 说明1
图片1 图片1 图片1 图片1
说明1 说明1 说明1 说明1
首 页 上一页 下一页 尾 页 页次:1/2页 6个记录/页 共9个记录 转到:select页
------解决方案-------------------- <table> <tr>
<td height= "60 " colspan= "2 "> </td>
</tr>
<!--#include file= "你的数据库连接文件 " -->
<%
dim table
table= "yourtable " '这里是你需要查询的数据表名
page=cint(request( "page "))
Set rs= Server.CreateObject( "ADODB.Recordset ")
sql= "select * from "&table& " order by id asc "
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write " <tr> <td> 对不起,还没有添加! </td> </tr> "
else
rs.PageSize=6
if page=0 then page=1
pages=rs.pagecount
if page > pages then page=pages
rs.AbsolutePage=page
i=0
for j=1 to rs.PageSize
%>
<td align= "center " width= "33% "> <Table> <tr> <td>
<a href= "连接地址 " target= "_blank "> <img src= "记录的图片路径如: <%=rs( "img ")%> " alt= "图片说明,可不填,如: <%=rs( "title ")%> " width= "110 " height= "143 " border= "0 "> </a>
</td>
</tr>
<tr> <td align= "center "> <%=rs( "title ")%> --> 图片标题
</td> </tr> </Table> </td>
<!--下面的不需要改-->
<%
rs.movenext
i=i+1
if i =3 then%>
</tr> <tr>
<%
i=0
end if
if rs.eof then exit for
next
%>
<tr bgcolor= "#FFFFFF "> <td height= "24 " colspan= "6 "> <p> </p>
<div align= "center "> <%if Page <2 then
response.write "首页 上一页 "
else
response.write " <a href=?page=1> 首页 </a> "
response.write " <a href=?page= " & Page-1 & "> 上一页 </a> "
end if
if rs.pagecount-page <1 then
response.write "下一页 尾页 "
else
response.write " <a href=?page= " & (page+1) & "> "
response.write "下一页 </a> <a href=?page= "&rs.pagecount& "> 尾页 </a> "
end if
response.write " 页次: <strong> <font color=red> "&Page& " </font> / "&rs.pagecount& " </strong> 页 "
response.write " 共 <b> <font color= '#FF0000 '> "&rs.recordcount& " </font> </b> 条记录 <b> "&rs.pagesize& " </b> 条记录/页 "
%>
</div> </td> </tr>
<%
end if
rs.close
set rs=nothing
%> </table>
<%
conn.close
set conn=nothing
%