asp读出数据后列表循环问题
<tablewidth="100%"height="100%"border="0"align="center"cellpadding="0"cellspacing="0"...
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<TR>
<%
Sql="select * from danye where B_ID="&B_id&" order by id"
Set Rs=Conn.Execute(Sql)
while not Rs.eof
%>
<TD width="67" height="28" align="right" style="PADDING-LEFT: 60px">
<div align="left">
<A href="about.asp?id=<%=rs("ID")%>"><%=rs("title")%></A>
</div></TD>
<%
rs.movenext
wend
rs.close
set rs=nothing
%>
</TR>
</table>
我想让上面程序把数据库读的数据变成每行显示10个的表格怎么做啊,在线等待,谢谢啊~ 展开
<TR>
<%
Sql="select * from danye where B_ID="&B_id&" order by id"
Set Rs=Conn.Execute(Sql)
while not Rs.eof
%>
<TD width="67" height="28" align="right" style="PADDING-LEFT: 60px">
<div align="left">
<A href="about.asp?id=<%=rs("ID")%>"><%=rs("title")%></A>
</div></TD>
<%
rs.movenext
wend
rs.close
set rs=nothing
%>
</TR>
</table>
我想让上面程序把数据库读的数据变成每行显示10个的表格怎么做啊,在线等待,谢谢啊~ 展开
3个回答
展开全部
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<%
Sql="select * from danye where B_ID="&B_id&" order by id"
Set Rs=Conn.Execute(Sql)
do while not rs.eof
%>
<TR>
<%for i=1 to 10
if not rs.eof then
%>
<TD width="67" height="28" align="right" style="PADDING-LEFT: 60px">
<div align="left">
<A href="about.asp?id=<%=rs("ID")%>"><%=rs("title")%></A>
</div></TD>
<%
rs.movenext
else
%>
<TD width="67" height="28" align="right" style="PADDING-LEFT: 60px">
<div align="left">
</div></TD>
<%
end if
next
%>
</TR> <%
loop
rs.close
set rs=nothing
%>
</table>
--------------
这样写就可以实现了,上午有点忙,所以没好好排版,有点乱,但是思路很清晰,楼主读下吧,如果有不明白的 可以百度HI找我
<%
Sql="select * from danye where B_ID="&B_id&" order by id"
Set Rs=Conn.Execute(Sql)
do while not rs.eof
%>
<TR>
<%for i=1 to 10
if not rs.eof then
%>
<TD width="67" height="28" align="right" style="PADDING-LEFT: 60px">
<div align="left">
<A href="about.asp?id=<%=rs("ID")%>"><%=rs("title")%></A>
</div></TD>
<%
rs.movenext
else
%>
<TD width="67" height="28" align="right" style="PADDING-LEFT: 60px">
<div align="left">
</div></TD>
<%
end if
next
%>
</TR> <%
loop
rs.close
set rs=nothing
%>
</table>
--------------
这样写就可以实现了,上午有点忙,所以没好好排版,有点乱,但是思路很清晰,楼主读下吧,如果有不明白的 可以百度HI找我
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<TR>
<%
i=0
Sql="select * from danye where B_ID="&B_id&" order by id"
Set Rs=Conn.Execute(Sql)
while not Rs.eof
i = i + 1
if i>10 then
%>
</TR><TR>
<%
i=1
endif
%>
<TD width="67" height="28" align="right" style="PADDING-LEFT: 60px">
<div align="left">
<A href="about.asp?id=<%=rs("ID")%>"><%=rs("title")%></A>
</div></TD>
<%
rs.movenext
wend
rs.close
set rs=nothing
if i<10 then
%>
<TD colspan=<%=10-i%>>&nbsp;</TD>
<%
endif
%>
</TR>
</table>
<TR>
<%
i=0
Sql="select * from danye where B_ID="&B_id&" order by id"
Set Rs=Conn.Execute(Sql)
while not Rs.eof
i = i + 1
if i>10 then
%>
</TR><TR>
<%
i=1
endif
%>
<TD width="67" height="28" align="right" style="PADDING-LEFT: 60px">
<div align="left">
<A href="about.asp?id=<%=rs("ID")%>"><%=rs("title")%></A>
</div></TD>
<%
rs.movenext
wend
rs.close
set rs=nothing
if i<10 then
%>
<TD colspan=<%=10-i%>>&nbsp;</TD>
<%
endif
%>
</TR>
</table>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<TR>
<%
Sql="select * from danye where B_ID="&B_id&" order by id"
Set Rs=Conn.Execute(Sql)
if not Rs.eof then
for i=1 to rs.recordcount
%>
<TD width="67" height="28" align="right" style="PADDING-LEFT: 60px">
<table width="100%" border="0">
<tr>
<td><div align="left">
<A href="about.asp?id=<%=rs("ID")%>"><%=rs("title")%></A>
</div></td>
</tr>
</table>
</TD>
<%
rs.movenext
if i mod 10 =0 then
response.Write("</TR>")
end if
next
end if
rs.close
set rs=nothing
%>
</table>
这样应该可以了 你试试
<TR>
<%
Sql="select * from danye where B_ID="&B_id&" order by id"
Set Rs=Conn.Execute(Sql)
if not Rs.eof then
for i=1 to rs.recordcount
%>
<TD width="67" height="28" align="right" style="PADDING-LEFT: 60px">
<table width="100%" border="0">
<tr>
<td><div align="left">
<A href="about.asp?id=<%=rs("ID")%>"><%=rs("title")%></A>
</div></td>
</tr>
</table>
</TD>
<%
rs.movenext
if i mod 10 =0 then
response.Write("</TR>")
end if
next
end if
rs.close
set rs=nothing
%>
</table>
这样应该可以了 你试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询