<%开始分页
Const MaxPerPage=4
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if
if nclassid="" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select top 20 * from shop_books order by adddate desc",conn,1,1
else
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_books where nclassid="&nclassid&" order by adddate desc",conn,1,1
end if
if err.number<>0 then
response.write "数据库中无数据"
end if
if rs.eof And rs.bof then
Response.Write "<p align=center class=contents> 对不起,此分类暂时还没有作品!</p>"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"class.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"class.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"class.asp"
end if
end if
end if
sub showContent
dim i
i=0
%>
关注
i=0
if i mod 4=0 then
<%
response.Write "<a href=book.asp?id="&rs("bookid")&">"
if trim(rs("bookpic"))<>"" then
response.Write "<img src="&trim(rs("bookpic"))&" width=90 height=110 border=0 ><%end if %></a>"<br>
else
<%
response.Write "<a href=book.asp?id="&rs("bookid")&">"
if trim(rs("bookpic"))<>"" then
response.Write "<img src="&trim(rs("bookpic"))&" width=90 height=110 border=0 ><%end if %></a>"
end if
这是控制显示图片转行的。
rs.pagesize=8 ‘定义为每页8条
你可以用
for i=1 to rs.recordcount step 4
然后用response.write"</tr>"
来控制表格就行了。
<%
rstemp.pagesize=8 8个图片
i = 0
for n=1 to rs.pagesize
%>
<table border="0">
<tr>
<% do while i <= 4 and not rs.EOF %> 一排四个图片
<td>
<img src="image/<% =rs("cpbm")%>" border="0"></a> 取图片地址
</td>
<%
if not rs.EOF then
rs.movenext
i = i + 1
else
exit do
end if
loop
%>
</tr>
</table>
<%
i = 0
n=n+1
next
rs.close
%>
<%
if not rs.eof then
%>
<table width="400" border="0" cellpadding="0" cellspacing="0">
<%
dim i
i=0
do while not rs.eof and i<=MaxPerPage
if i<4 then
%>
<tr>
<td>
<div align="center">
<%
response.Write "<a href=book.asp?id="&rs("bookid")&">"
if trim(rs("bookpic"))<>"" then
response.Write "<img src="&trim(rs("bookpic"))&" width=90 height=110 border=0 ></a>"
else
response.Write "<img src=images/emptybook.gif width=90 height=110 border=0></a>"
end if
%>
</div>
<div align="center"> <a href=book.asp?id=<%=rs("bookid")%>><font color="#FF871A"><%=trim(rs("bookname"))%></font></a> </div></td>
<%
i=i+1
rs.movenext
%>
</tr>
<%
else
%>
<tr>
<td>
<div align="center">
<%
response.Write "<a href=book.asp?id="&rs("bookid")&">"
if trim(rs("bookpic"))<>"" then
response.Write "<img src="&trim(rs("bookpic"))&" width=90 height=110 border=0 ></a>"
else
response.Write "<img src=images/emptybook.gif width=90 height=110 border=0></a>"
end if
%>
</div>
<div align="center"> <a href=book.asp?id=<%=rs("bookid")%>><font color="#FF871A"><%=trim(rs("bookname"))%></font></a> </div></td>
<%
i=i+1
rs.movenext
%>
</td>
</tr>
<%
end if
loop
%>
</table>
<%
else
response.write "无图片!"
end if
rs.close
set rs=nothing
%>