如何解决两个for的冲突?

good3g 2008-07-19 04:30:58
下面这两个for之间有部突
dim xx,aid
xx="1,2,3,4"
aid=split(xx,",")
for i=0 to 3

Set Rs7 = Server.CreateObject("Adodb.Recordset")
Sql7 = "SELECT top 500 Title FROM Article where aid="& aid(i)&" order by id desc"
Rs7.Open Sql7,conn,1,1
if not (rs7.bof and rs7.eof) then
if rs7.RecordCount>5 then
aaaaa=5
else
aaaaa=rs7.RecordCount
end if
if aid=1 Response.Write "分类1"
if aid=2 Response.Write "分类2"

For i=1 to aaaaa
Response.Write ("(utf8(rs7("Title"))<br/>")
Rs7.MoveNext
Next
end if
Rs7.close
set rs7=nothing

next
...全文
75 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Anlige 2008-07-19
  • 打赏
  • 举报
回复

dim xx,aid
xx="1,2,3,4"
aid=split(xx,",")
for i=0 to 3

Set Rs7 = Server.CreateObject("Adodb.Recordset")
Sql7 = "SELECT top 500 Title FROM Article where aid="& aid(i)&" order by id desc"
Rs7.Open Sql7,conn,1,1
if not (rs7.bof and rs7.eof) then
if rs7.RecordCount>5 then
aaaaa=5
else
aaaaa=rs7.RecordCount
end if
if aid=1 then Response.Write "分类1"
if aid=2 then Response.Write "分类2"

For j=1 to aaaaa
Response.Write ("(utf8(rs7("Title")) <br/>")
Next
Rs7.MoveNext
end if
Rs7.close
set rs7=nothing
next
Anlige 2008-07-19
  • 打赏
  • 举报
回复
就是啊~两个for里面的循环变量一样的话那不麻烦了~

----------------------------^_^大家一起学习^_^------------------------------
艾恩ASP学习博客 http://blog.ii-home.cn

Email:zhanghuiguoanlige@126.com QQ:417833272
jhwcd 2008-07-19
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 good3g 的回复:]
我还没有应用成功啊!
[/Quote]
现在还不行吗,提示什么错误?
good3g 2008-07-19
  • 打赏
  • 举报
回复
我还没有应用成功啊!
Msxindl_Com 2008-07-19
  • 打赏
  • 举报
回复
老兄,你这个方法是我在
http://topic.csdn.net/u/20080718/19/a7cd76d7-4bc8-4d5b-9dfc-114b8429e265.html
中给你的吧.既然用了此方法,为何不结贴呢?

把其中一个FOR的变量i换成其它变量名即可.
jhwcd 2008-07-19
  • 打赏
  • 举报
回复
dim xx,aid 
xx="1,2,3,4"
aid=split(xx,",")
for i=0 to 3

Set Rs7 = Server.CreateObject("Adodb.Recordset")
Sql7 = "SELECT top 500 Title FROM Article where aid="& aid(i)&" order by id desc"
Rs7.Open Sql7,conn,1,1
if not (rs7.bof and rs7.eof) then
if rs7.RecordCount>5 then
aaaaa=5
else
aaaaa=rs7.RecordCount
end if
if aid=1 Response.Write "分类1"
if aid=2 Response.Write "分类2"

For j=1 to aaaaa
if rs7.eof then
exit for
end if
Response.Write ("(utf8(rs7("Title")) <br/>")
Rs7.MoveNext
Next
end if
Rs7.close
set rs7=nothing

next
jhwcd 2008-07-19
  • 打赏
  • 举报
回复
两个FOR循环变量不能一样吧。
dim xx,aid 
xx="1,2,3,4"
aid=split(xx,",")
for i=0 to 3

Set Rs7 = Server.CreateObject("Adodb.Recordset")
Sql7 = "SELECT top 500 Title FROM Article where aid="& aid(i)&" order by id desc"
Rs7.Open Sql7,conn,1,1
if not (rs7.bof and rs7.eof) then
if rs7.RecordCount>5 then
aaaaa=5
else
aaaaa=rs7.RecordCount
end if
if aid=1 Response.Write "分类1"
if aid=2 Response.Write "分类2"

For j=1 to aaaaa
if rs7.eof then
exit for
end if
Response.Write ("(utf8(rs7("Title")) <br/>")
Rs7.MoveNext
Next
end if
Rs7.close
set rs7=nothing

next



daxiong521 2008-07-19
  • 打赏
  • 举报
回复
试试把其中一个FOR的变量i换成其它变量名!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧