图片多行多列分页出现错误,多出一页,大家帮忙看看错在哪,源码如下

hukejie 2004-11-25 09:27:18
<!--#include file="conn/conn2.asp"-->
<%
set rsjing=server.CreateObject("ADODB.RECORDSET")
sqljing="select * from product order by addtime desc"
rsjing.open sqljing,conn,3,2

rsjing.pagesize=8
topage=clng(request("topage"))
if topage=0 then
topage=1
elseif topage>rsjing.pagecount then
topage=rsjing.pagecount
end if%>
<%

if rsjing.eof then
response.Write("太不可思议了,什么都没找到!!")
else
rsjing.absolutepage=topage%></font></strong></div></td>
</tr>
<tr>
<td height="10"> </td>
</tr>
<tr>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
<td valign="top"><table width="100%" border="0" cellpadding="2" cellspacing="2">
<%


for a=1 to rsjing.pagesize
if rsjing.eof then
exit for
end if
%>
<tr> <%for i=1 to 4
if rsjing.eof then
exit for
end if%>
<td height="178" align="center">
<table width="25%" border="0" cellpadding="0" cellspacing="1" bgcolor="#999999">
<tr>
<td align="center" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td height="120" align="center"><% if len(rsjing("imgpath"))>21 then %><a href="product_view2.asp?id=<%=rsjing("id")%>"><img src="pic/<%=rsjing("imgpath")%>" alt="<%=rsjing("id")%>" border="0" width="100" height="100"></a><%else%><img src="images/cpx.gif" border="0" width="100" height="100"><%end if%></td>
</tr>
<tr>
<td align="center">名称:
<a href="product_view2.asp?id=<%=rsjing("id")%>">
<%=rsjing("name")%>
</a></td>
</tr>
</table></td>
</tr>
</table></td> <%rsjing.movenext
next
%>
</tr><%next
'rsjing.close
%>


</table>
<table width="100%" border="0">
<tr>
<td height="1" bgcolor="#CCCCCC"></td>
</tr>
<tr>
<td><div align="center"><TABLE width="60%"
border=0 cellPadding=4 cellSpacing=0>
<TBODY>
<TR class=word>
<TD>共<SPAN class=en><%=rsjing.recordcount%></SPAN>条</TD>
<TD align=middle>
<TABLE width="100%"
border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR align=middle>
<TD class=word><a href="ProList.asp?topage=<%=1%>"><font color="#000000">首页</font></a> </TD>
<TD class=word><a href="ProList.asp?topage=<%=topage-1%>"><font color="#000000">上一页</font></a> </TD>
<TD class=word><A
href="ProList.asp?topage=<%=topage+1%>"><font color="#000000">下一页</font></A> </TD>
<TD class=word><A
href="ProList.asp?topage=<%=rsjing.pagecount%>"><font color="#000000">末页</font></A> </TD>
<TD class=word>第<SPAN class=en><FONT
color=#ff6600><B><%=topage%></B></FONT></SPAN>页 / 共<SPAN
class=en><%=rsjing.pagecount%></SPAN>页</TD>
</TR>
</TBODY>
</TABLE></TD>
<%end if%>
...全文
102 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hukejie 2004-11-26
  • 打赏
  • 举报
回复
谢谢各位,问题解决
hflsj 2004-11-25
  • 打赏
  • 举报
回复
<table><tr>
<% i=0
'num 为从数据库中读取的数目
For a=1 to num
i=i+1
Response.Write "<td>" & 你的图片内容 & "<td>"
If (i mod 4)=0 Then
response.write "</tr><tr>"
End If
Next
%>
</tr></table>
jinhong618 2004-11-25
  • 打赏
  • 举报
回复
为什么要双层循环呢,单层就一可以了:
For a=1 to rsjing.pagesize
If ((a-1) mod 4)=0 Then
Response.Write "<tr>"
End If
Response.Write "<td>" & 你的内容 & "<td>"

rsjing.movenext
If (Rsjing.Eof) Then
Response.Write "</tr>"
End If
If (a mod 4)=0 and not Rsjing.Eof Then
Response.Write "</tr>"
End If
Next

自己调试一下吧,每行写了四个内容。
lienzhu 2004-11-25
  • 打赏
  • 举报
回复
你定义的rsjing.pagesize=8
可你这样写
for a=1 to rsjing.pagesize
for i=1 to 4
rsjing.movenext
next
next
实际上是32条数据
要不改成

你定义的rsjing.pagesize=32
可你这样写
for a=1 to 8
for i=1 to 4
rsjing.movenext
next
next

hukejie 2004-11-25
  • 打赏
  • 举报
回复
想要显行多行,并不是2行
lienzhu 2004-11-25
  • 打赏
  • 举报
回复
for a=1 to rsjing.pagesize

改为
for a=1 to 2

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧