表格显示固定数量图片的问题

idc868 2007-06-05 11:27:14
我想在表格里显示图片,可是我这个会把所有的图片都在一行里显示,我想每行显示5个图片,一到五个自动换行,也就是一行五列,请问怎么实现?下面是我现在的代码,谢谢了
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from huajia order by id desc",conn,1,1
if rs.eof and rs.bof then
response.write "现在还没有填加内容!"
else
do while not rs.eof
%>
<table><tr><td>
<a href=<%response.write server.URLEncode("xq01.asp")%>?huajiam=<%=rs("huajiam")%> target="_blank" class="gray">
<img src="<%=rs("huajiam")%>" width="100" height="100"> </a> </td></tr></table>


<%rs.movenext
loop
end if
rs.close
set rs=nothing%>
...全文
538 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
idc868 2007-06-05
  • 打赏
  • 举报
回复
改成下面的了,可是不行,下面是效果地址http://cnc.yanwange.com/ghcp.asp,他把每一个都循环了6次,下面是代码,看看怎么改,谢谢了
<table width="760" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from zuopin order by id desc",conn,1,1
if rs.eof and rs.bof then
response.write "现在还没有填加内容!"
else
do while not rs.eof
%>

<%for i = 1 to rs.recordcount%>

<td width="100" align="left" valign="top">


<a href='xq02.asp?id=<%=rs("id")%>' target="_blank" class="gray" title='<%=rs("picm")%>'>
<img src="<%=rs("bookpic")%>" width="100" height="100"> </a>






</td>
<%if i mod 5 = 0 then response.write "</tr><tr>"
next%>

<%rs.movenext
loop
end if
rs.close
set rs=nothing%>
</tr>

</table>
liooon 2007-06-05
  • 打赏
  • 举报
回复
用for 来控制,response.write输出
idc868 2007-06-05
  • 打赏
  • 举报
回复
怎么就没人知道呢
idc868 2007-06-05
  • 打赏
  • 举报
回复
没有人回答么
lianghaitao2007 2007-06-05
  • 打赏
  • 举报
回复
<table>
<tr>
<td width="100%" height="25">
<table border="0" cellpadding="0" width="100%" align="center">
<tr align="center"><%
set rs=server.createobject("adodb.recordset")
rs.open "select * from huajia order by id desc",conn,1,1
do while not (rs.eof or err)
%>

<td>
<a href=<%response.write server.URLEncode("xq01.asp")%>?huajiam=<%=rs("huajiam")%> target="_blank" class="gray">
<img src="<%=rs("huajiam")%>" width="100" height="100"> </a> </td><%ka=ka+1
if ka=5 then
ka=0 %></tr>
<%end if
rs.MoveNext
Loop
%>
</table></td>
</tr></table>


再试试这个!!!
上面哪个好象有问题!!!
lianghaitao2007 2007-06-05
  • 打赏
  • 举报
回复
<table><tr>
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from huajia order by id desc",conn,1,1
do while not (rs.eof or err)
%>
<td>
<a href=<%response.write server.URLEncode("xq01.asp")%>?huajiam=<%=rs("huajiam")%> target="_blank" class="gray">
<img src="<%=rs("huajiam")%>" width="100" height="100"> </a> </td>
<%
ka=ka+1
if ka=5 then
ka=0
%>
</tr>
<%
end if
%>

<%rs.movenext
loop
%>
</table>
<%
rs.close
set rs=nothing%>
idc868 2007-06-05
  • 打赏
  • 举报
回复
不行他总是把每个图都显示6次才换下个图
snlixing 2007-06-05
  • 打赏
  • 举报
回复
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from zuopin order by id desc",conn,1,1
if rs.eof and rs.bof then
response.write "现在还没有填加内容!"
else
do while not rs.eof

response.write("<tr>")
for i=1 to rs.recordcount
if (i mod 5==0) then
response.write("<td width=100 height=100>")
response.write("<a href=xq02.asp?id="&rs("id")&" target=_blank class=gray title="&rs("picm")&"><img src="&rs("bookpic")&" width=100 height=100></a></td>")
end if
rs.movenext
i=i+1
next
response.write("</tr>")
rs.movenext
loop
end if
rs.close
set rs=nothing%>
idc868 2007-06-05
  • 打赏
  • 举报
回复
还是不行呀,大哥们,小弟跪求了,谁能给个可以正常用的吧!今天必须完成呀
snlixing 2007-06-05
  • 打赏
  • 举报
回复
i=1
do while not rs.eof and i<rs.recordcount
if (i mod 5=0) then
response.write("<td width=100 height=100>")
response.write("<a href=xq02.asp?id="&rs("id")&" target=_blank class=gray title="&rs("picm")&"><img src="&rs("bookpic")&" width=100 height=100></a></td>")
end if
rs.movenext
i=i+1
loop
response.write("</tr>")
rs.movenext
loop
end if
rs.close
set rs=nothing%>
idc868 2007-06-05
  • 打赏
  • 举报
回复
帮帮忙吧
idc868 2007-06-05
  • 打赏
  • 举报
回复
现在改成了这样,可是只显示5个,其余的不显示了,怎么弄呀
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from zuopin order by id desc",conn,1,1
if rs.eof and rs.bof then
response.write "现在还没有填加内容!"
else
do while not rs.eof

response.write("<tr>")
i=1
do while not rs.eof and i<=5
response.write("<td width=100 height=100>")
response.write("<a href=xq02.asp?id="&rs("id")&" target=_blank class=gray title="&rs("picm")&"><img src="&rs("bookpic")&" width=100 height=100></a></td>")
rs.movenext
i=i+1
loop
response.write("</tr>")
rs.movenext
loop
end if
rs.close
set rs=nothing%>
angelhualing 2007-06-05
  • 打赏
  • 举报
回复
do while not rs.eof
response.write("<tr>")
i=1
do while not rs.eof and i<=5
response.write("<td><img...></td>")
rs.movenext
i=i+1
loop
response.write("</tr>")
loop


liooon 2007-06-05
  • 打赏
  • 举报
回复
把你要循环输出的部分,用reponse.write 来输出,思路如下:
先输出行,然后循环输出5个单元格;达到5个后,跳出内循环;再重复前面的步骤;直到rs.eof为真,输出完闭。

28,391

社区成员

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

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