ASP图片分页代码 (通用)
时间:2009-06-22 12:57:00
<table width="636" border="0" align="center" cellpadding="0" cellspacing="0">
<%
dim k,n 'k为显示的行数 n是一行显示的个数
set rs=server.createobject("adodb.recordset")
sql="select * from photo where hidden=true and c_id=92 order by id desc"
rs.open sql,conn,1,1
IF not rs.eof Then
proCount=rs.recordcount
rs.PageSize=8 '定义显示数目
n=4 '每行显示的数目
If rs.pagesize Mod n=0 Then
k=rs.pagesize/n
Else
k=rs.pagesize/n +1
End If
if not IsEmpty(Request("ToPage")) then
ToPage=CInt(Request("ToPage"))
if ToPage>rs.PageCount then
rs.AbsolutePage=rs.PageCount
intCurPage=rs.PageCount
elseif ToPage<=0 then
rs.AbsolutePage=1
intCurPage=1
else
rs.AbsolutePage=ToPage
intCurPage=ToPage
end if
else
rs.AbsolutePage=1
intCurPage=1
end if
intCurPage=CInt(intCurPage)
Dim ii, ij, im
ii=0
im=0
do while Not rs.eof And ii<k
%>
<tr>
<%
for ij=1 to n
%>
<td><table width="150" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="3">
<tr>
<td><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="120" height="150" border="0" cellpadding="1" cellspacing="1" bgcolor="#666600">
<tr>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="120" height="150" background="images/Wallpaper_5.jpg"><span class="unnamed2"><a href="photo_view.asp?id=<%=rs("id")%>" target=_blank><img src="upload/<%=rs("spic")%>" width="120" height="150" border="0" /></a></span></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td>
<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center"><font color="#E23C08">
<% if len(rs("name"))<=8 then
Response.write rs("name")
else
response.write left(rs("name"),8)&"..."
end if
%>
</font></div></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<%
rs.movenext
if rs.eof then exit for
if rs.eof then exit do
Next
%>
</tr>
<%
ii=ii+1
im=im+1
If im>rs.pagesize Then Exit do
Loop
%>
</table>
<table width="636" height="57" border="0" cellpadding="0" cellspacing="0" align=center>
<tr>
<td height="56">
<div align="right"><span style="font-size: 9pt;"> 总共:<font color="#ff0000"><%=rs.PageCount%></font>页, <font color="#ff0000"><%=proCount%></font>个产品, 当前页:<font color="#ff0000"> <%=intCurPage%> </font>
<% if intCurPage<>1 then
%>
<a href="?ToPage=1">首页</a>ws<a href="?ToPage=<%=intCurPage-1%>">上一页</a>ws
<% end if
if intCurPage<>rs.PageCount then %>
<a href="?ToPage=<%=intCurPage+1%>">下一页</a>ws<a href="?ToPage=<%=rs.PageCount%>"> 最后一页</a>
<% end if%>
</span></div>
</form>
<div align="right">
<%end if%>
</div></td>
</tr>
</table>