asp循环输出的问题
setrs1=Server.CreateObject("Adodb.Recordset")sql1="select*fromgalleryorderbygallery_i...
set rs1=Server.CreateObject("Adodb.Recordset")
sql1="select * from gallery order by gallery_id DESC"
rs1.open sql1,conn,1,1
set rs2=Server.CreateObject("Adodb.Recordset")
sql2="select * from images where Image_Galleryid="&rs1("gallery_id")&" "
rs2.open sql2,conn,1,1
for j=0 to rs1.recordcount-1
classurl=classurl&"<item>"&vbcrlf
classurl=classurl&"<输出rs1>"&vbcrlf
for k=0 to rs2.recordcount-1
classurl=classurl&"<image>"&vbcrlf
classurl=classurl&"<输出rs2>"&vbcrlf
classurl=classurl&"</image>"&vbcrlf
rs2.movenext
next
classurl=classurl&"</item>"&vbcrlf
rs1.movenext
next
代码如上。我要实现如下循环,总是不对。请教高手。谢谢。:
<item>
输出rs1
输出rs1
输出rs1
<image>
输出rs2
输出rs2
输出rs2
<image>
<item>
<item>
------
------
------
<image>
------
------
------
<image>
<item>
<item>
------
------
------
<image>
------
------
------
<image>
<item> 展开
sql1="select * from gallery order by gallery_id DESC"
rs1.open sql1,conn,1,1
set rs2=Server.CreateObject("Adodb.Recordset")
sql2="select * from images where Image_Galleryid="&rs1("gallery_id")&" "
rs2.open sql2,conn,1,1
for j=0 to rs1.recordcount-1
classurl=classurl&"<item>"&vbcrlf
classurl=classurl&"<输出rs1>"&vbcrlf
for k=0 to rs2.recordcount-1
classurl=classurl&"<image>"&vbcrlf
classurl=classurl&"<输出rs2>"&vbcrlf
classurl=classurl&"</image>"&vbcrlf
rs2.movenext
next
classurl=classurl&"</item>"&vbcrlf
rs1.movenext
next
代码如上。我要实现如下循环,总是不对。请教高手。谢谢。:
<item>
输出rs1
输出rs1
输出rs1
<image>
输出rs2
输出rs2
输出rs2
<image>
<item>
<item>
------
------
------
<image>
------
------
------
<image>
<item>
<item>
------
------
------
<image>
------
------
------
<image>
<item> 展开
1个回答
展开全部
set rs1=Server.CreateObject("Adodb.Recordset")
set rs2=Server.CreateObject("Adodb.Recordset")
sql1="select * from gallery order by gallery_id DESC"
rs1.open sql1,conn,1,1
for j=0 to rs1.recordcount-1
classurl=classurl&"<item>"&vbcrlf
classurl=classurl&"<输出rs1>"&vbcrlf
sql2="select * from images where Image_Galleryid="&rs1("gallery_id")&" "
rs2.open sql2,conn,1,1
for k=0 to rs2.recordcount-1
classurl=classurl&"<image>"&vbcrlf
classurl=classurl&"<输出rs2>"&vbcrlf
classurl=classurl&"</image>"&vbcrlf
rs2.movenext
next
rs2.close
classurl=classurl&"</item>"&vbcrlf
rs1.movenext
next
rs1.close
维度IDC 解答
set rs2=Server.CreateObject("Adodb.Recordset")
sql1="select * from gallery order by gallery_id DESC"
rs1.open sql1,conn,1,1
for j=0 to rs1.recordcount-1
classurl=classurl&"<item>"&vbcrlf
classurl=classurl&"<输出rs1>"&vbcrlf
sql2="select * from images where Image_Galleryid="&rs1("gallery_id")&" "
rs2.open sql2,conn,1,1
for k=0 to rs2.recordcount-1
classurl=classurl&"<image>"&vbcrlf
classurl=classurl&"<输出rs2>"&vbcrlf
classurl=classurl&"</image>"&vbcrlf
rs2.movenext
next
rs2.close
classurl=classurl&"</item>"&vbcrlf
rs1.movenext
next
rs1.close
维度IDC 解答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询