asp循环语句怎么写

来源:百度知道 编辑:UC知道 时间:2024/09/27 23:32:26
下面代码读出10条数据,怎么让它成为2行。每行显示5条?

sub disk_top(n_num,c_num)
response.write vbcrlf&music_bar_top("left_disk_good",0)
n_name="专辑"
sql="select top 10 name,pic,hits,id from music_disk where hidden=1 order by id desc"
set rs=joekoe_cms.exec(sql,1)
do while not rs.eof
n_topic=rs("name")
pic=rs("pic")
n_topic=joekoe_cms.code_js(n_topic,1)
response.write "<table><tr>" & _
vbcrlf&"<td align=right class=tims>"&"<img src='"&rs("pic")&"'width='120' border='0'>""</td>" &_
vbcrlf&"</tr><tr>"&_
vbcrlf&"<td ><a href='javascript:;' onclick=javascript:open_view('music_disk_view.asp?id="&rs("id")&"',1); alt='浏览专辑:"&joekoe_cms.code_html(n_topic,1,0)&"'

循环部分改为:
i=0
do while not rs.eof
i=i+1
n_topic=rs("name")
pic=rs("pic")
n_topic=joekoe_cms.code_js(n_topic,1)
response.write "<table><tr>" & _
vbcrlf&"<td align=right class=tims>"&"<img src='"&rs("pic")&"'width='120' border='0'>""</td>" &_
vbcrlf&"</tr><tr>"&_
vbcrlf&"<td ><a href='javascript:;' onclick=javascript:open_view('music_disk_view.asp?id="&rs("id")&"',1); alt='浏览专辑:"&joekoe_cms.code_html(n_topic,1,0)&"'>"&joekoe_cms.code_html(n_topic,1,c_num)&"</a></td>" & _
vbcrlf&"</tr>" & _
vbcrlf&"</table>"
if i=5 then
response.write "<table><tr><td colspan=""2"" height=""10&quo