asp 循环输出表格
想要循环输出一副图片和文字<tablewidth="100%"border="0"cellspacing="0"cellpadding="0"><tr><%setrs1=...
想要循环输出一副图片和文字
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<%
set rs1=server.createobject("ADODB.Recordset")
sql1="select Top 2 ID,Title,Images from Yao_Article where ClassID=119 and IsImg=1 order by ID desc"
rs1.open sql1,conn,1,3
If Not rs1.Eof Then
do while not (rs1.eof or err)
%>
<td ><a href="<%=SitePath%><%If html=1 then Response.Write("article.asp?ID="&rs1("ID")&"") else:if html=3 then Response.Write("article/"&rs1("ID")&".html") End if%>" title="<%=rs1("Title")%>" target="_blank"><img src="<%=SitePath%><%=SiteUp%>/<%if IsAspJpeg=1 then Response.Write("s250/") End if%><%=rs1("Images")%>" width="92" height="112" border="0" style="border:1px #517DA0 solid" /></a></td>
<%rs1.movenext
loop
else
Response.Write("<tr><td>暂无信息</td></tr>")
end if
rs1.close
set rs1=nothing
%>
</tr>
</table> 展开
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<%
set rs1=server.createobject("ADODB.Recordset")
sql1="select Top 2 ID,Title,Images from Yao_Article where ClassID=119 and IsImg=1 order by ID desc"
rs1.open sql1,conn,1,3
If Not rs1.Eof Then
do while not (rs1.eof or err)
%>
<td ><a href="<%=SitePath%><%If html=1 then Response.Write("article.asp?ID="&rs1("ID")&"") else:if html=3 then Response.Write("article/"&rs1("ID")&".html") End if%>" title="<%=rs1("Title")%>" target="_blank"><img src="<%=SitePath%><%=SiteUp%>/<%if IsAspJpeg=1 then Response.Write("s250/") End if%><%=rs1("Images")%>" width="92" height="112" border="0" style="border:1px #517DA0 solid" /></a></td>
<%rs1.movenext
loop
else
Response.Write("<tr><td>暂无信息</td></tr>")
end if
rs1.close
set rs1=nothing
%>
</tr>
</table> 展开
展开全部
<table>
<%
cell_num=3
Control_num=0
do while not rs.eof
if Control_num mod cell_num=0 then
Response.write "<tr>"
end if
Response.write "<td>"&rs(0)&?"</td>"
if Control_num mod cell_num=0 then
Response.write "</tr>"
end if
control_num=control_num+1
rs.movenext
loop
%>
</table>
利用模来控制换行,例子给你了,看懂了自己照着改!你的程序错误在于rs.movenext后,没有检测是否rs.eof
<%
cell_num=3
Control_num=0
do while not rs.eof
if Control_num mod cell_num=0 then
Response.write "<tr>"
end if
Response.write "<td>"&rs(0)&?"</td>"
if Control_num mod cell_num=0 then
Response.write "</tr>"
end if
control_num=control_num+1
rs.movenext
loop
%>
</table>
利用模来控制换行,例子给你了,看懂了自己照着改!你的程序错误在于rs.movenext后,没有检测是否rs.eof
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询