纯电动车龙头股:ASP图片怎么换行

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 02:17:10
我的图片是从数据库调用的,我想让他横着放四个小图一排,竖着放三个小图一排,我应该怎么写,我写的代码如下,应该怎么改,

<%
else
if rs.recordcount<3 then
j=1
else
j=3
end if
for i=1 to j %>
<tr>
<% for k=1 to 5 %>

<td width="150" height="123
"><a href="ima.asp?id=<%=rs("编号")%>"><img src="upload/image/<%=rs("大图")%>" width="150" height="123" border="0"></a></td>
<% rs.movenext
if rs.eof then exit for
next %>
</tr>
<% next
end if
%>
最好在我的基础上改,谢谢了
希望大家能帮帮我,我是asp初学者,QQ 58738171
如有ps 3d 数码方面的问题可以相互交流,谢谢

<%

for i=1 to 3
if rs.eof then exit for %>

<tr>
<% for k=1 to 4 %>

<td width="150" height="123
"><a href="ima.asp?id=<%=rs("编号")%>"><img src="upload/image/<%=rs("大图")%>" width="150" height="123" border="0"></a></td>
<% rs.movenext
if rs.eof then exit for
next

%>
</tr>
<%
if rs.eof then exit for
next
end if
%>

<table width="100%" cellpadding="0" cellspacing="0">
<%
sub showImg(sql,rows,cols,w,h)
dim rs,i,url_arr,counts
i=0
counts = rows * cols
set rs = server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1
' if rs.eof or rs.bof then
' response.write
' response.end
' end if
while int(i) < int(counts) and not rs.eof
if i mod cols = 0 then
response.write "<tr>"
end if
url_arr = split(rs("pic"),",")
response.write "<td width=" & int(100/cols) & "% >"
%>
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="4" class="login">
<tr>
<td><img src="<%if ubound(url_arr)>=0 then response.write url_arr(0) end if%>" width=<%=w%> height=<%=h%> style="cursor:hand;" onClick="location.href='qy-a.asp?id=<%=rs("id")%>&msgType=<%=rs("type")%>'" alt="<%=rs("area")%>"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2" height="30"> <div align="center"><%=autoCut(rs("title"),30)%></div></td>
</tr>
</table>
<%
response.write "</td>"
i = i + 1
if i mod cols = 0 then
response.write "</tr>"
end if
rs.movenext
wend
if int(i) mod int(cols) <> 0 then
response.write "<td width=" & 20*(cols-(i mod cols)) & "% colspan=" & (cols-(i mod cols)) & "> </td></tr>"
end if
end sub
showImg "select * from gyfc where isChecked=1 and isShow=1 order by post_time desc",2,5,112,75
%>
</table>
把调用的sql改成你的,和显示的格式块做一点修改就OK了!

<%
else
%><tr>
<%
i=0
do while not rs.eof and i<12
i=i+1
%>
<td width="150" height="123 "><a href="ima.asp?id=<%=rs("编号")%>"><img src="upload/image/<%=rs("大图")%>" width="150" height="123" border="0"></a></td>
<%
if i mod 4=0 then
response.Write("</tr><tr>")
end if
rs.movenext
loop
%></tr>
<%
end if
%>

关键是“if i mod 4=0 then
response.Write("</tr><tr>")
end if ”.