数据库中的图片一排一排的显示

叫我梁大侠 2010-08-18 12:04:30
我这好急额
我这弄个图片展示的
我输出显示的时候发现 弄不来一排一排的显示
我写的是

<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from product_info",conn,1,3
do while not rs.eof
%>
<table border='0' cellpadding='0' cellspacing='0' ><tr><td style='text-decoration: underline; border: 1px solid #CCCCCC;' align='center' width='180' height='200'><a href='ProductsView.asp?id=<%=Rs("id")%>' target='_blank'><img src=<%=rs("p_img")%> border=0 ></a></td>
</tr><tr><td height='36' align='center'> <a href='ProductsView.asp?id=<%=Rs("id")%>' target='_blank'><font color="#FFFFFF"><%=rs("p_title")%></font></a></td></tr>
</table>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
输出结果却是一条竖的图片
我想要的效果是 每行显示3张图片
然后显示两排
高人指点下,跪谢!
...全文
85 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
gorebao 2010-08-18
  • 打赏
  • 举报
回复

<table border='0' cellpadding='0' cellspacing='0' ><tr>
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from product_info",conn,1,3
For i = 1 to rs.recordcount
%>
<td style='text-decoration: underline; border: 1px solid #CCCCCC;' align='center' width='180' height='200'><a href='ProductsView.asp?id=<%=Rs("id")%>' target='_blank'><img src=<%=rs("p_img")%> border=0 ></a></td>
</tr><tr><td height='36' align='center'> <a href='ProductsView.asp?id=<%=Rs("id")%>' target='_blank'><font color="#FFFFFF"><%=rs("p_title")%></font></a></td>
<%if i mod 3=0 then response.Write("</tr><tr>")
rs.movenext
if rs.eof then exit for
next
rs.close
set rs=nothing
%>
</tr>
</table>
gorebao 2010-08-18
  • 打赏
  • 举报
回复
你循环table怎么会一排一排显示呢,你可以循环td呀,或是tr呀
gzpepco 2010-08-18
  • 打赏
  • 举报
回复
这种应用用ul li会比table更好控制
z109876543210 2010-08-18
  • 打赏
  • 举报
回复
<table border='0' cellpadding='0' cellspacing='0' style="float:left;margin:0 8px" >

margin:0 8px ,自己调整到可以刚好自动换行
街头小贩 2010-08-18
  • 打赏
  • 举报
回复
街头小贩 2010-08-18
  • 打赏
  • 举报
回复
建议你用CSS控制一行显示几个!用ASP控制要作换行和补位判断
街头小贩 2010-08-18
  • 打赏
  • 举报
回复
一行几个换行tr就行了
ttt2 2010-08-18
  • 打赏
  • 举报
回复
response.Write "<a href='"&rs("partners_link")&"'>"&rs("partners_title")&"</a>"
叫我梁大侠 2010-08-18
  • 打赏
  • 举报
回复
恩 谢谢大哥
弱弱的问下
大哥能帮我看下这语句怎么写才是对的?
response.Write "<a href='"&rs("partners_link")&"'>rs("partners_title")</a>"
gorebao 2010-08-18
  • 打赏
  • 举报
回复
不好意思,我看错了,
<table border='0' cellpadding='0' cellspacing='0' ><tr>
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from product_info",conn,1,3
For i = 1 to rs.recordcount
%>
<td><table><tr>
<td style='text-decoration: underline; border: 1px solid #CCCCCC;' align='center' width='180' height='200'><a href='ProductsView.asp?id=<%=Rs("id")%>' target='_blank'><img src=<%=rs("p_img")%> border=0 ></a></td>
</tr><tr><td height='36' align='center'> <a href='ProductsView.asp?id=<%=Rs("id")%>' target='_blank'><font color="#FFFFFF"><%=rs("p_title")%></font></a></td>
</tr></table></td>
<%if i mod 3=0 then response.Write("</tr><tr>")
rs.movenext
if rs.eof then exit for
next
rs.close
set rs=nothing
%>
</tr>
</table>

你在试下!
gorebao 2010-08-18
  • 打赏
  • 举报
回复
怎么不行?你Q多少?
叫我梁大侠 2010-08-18
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 gorebao 的回复:]
<table border='0' cellpadding='0' cellspacing='0' ><tr>
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from product_info",conn,1,3
For i = 1 to rs.recordcount
%>
<td style='……
[/Quote]
谢谢你啊 可是问题是弄出来还是不行哦
叫我梁大侠 2010-08-18
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 icepoint_chongqing 的回复:]
用DIV或者LI.

直接用ASP循环, 然后在CSS定议一个大DIV(限宽). 里边的小DIV放图, 设为左对齐

代码:

<div style="width:300px">
<%for i=1 to 9%>
<div style="float:left;width:100px">图片</div>
<%next%>
</div>
[/Quote]
谢谢你啊 可是按你的构思做出来的只是一行的
而且不会换行额
Icepoint_chongqing 2010-08-18
  • 打赏
  • 举报
回复
用DIV或者LI.

直接用ASP循环, 然后在CSS定议一个大DIV(限宽). 里边的小DIV放图, 设为左对齐

代码:

<div style="width:300px">
<%for i=1 to 9%>
<div style="float:left;width:100px">图片</div>
<%next%>
</div>

28,391

社区成员

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

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