循环嵌套问题——数据库记录不能循环
先附上图片:" border="0" />
图上两个背景蓝色的块中各包含着三个小块,就是写着“阴道炎”的那些,这是设计图样,实际上每块都是不同的,比如还有其他什么“炎”之类的。
每个“**炎”对应是一条数据库记录。
问题就是:怎么用程序把所有的数据库记录都调出来,并且每三个做为一组,构成一大块,就是图中背景是蓝色的那部分?
比如,如果数据库中有10条记录(10个**炎),那总共就应该有四个蓝色大块,其中第四个里面只有一个小版块,其余三个大块里都是各有三个版块。
下面是我的代码:
dim i, k, m
set rsw=server.CreateObject("adodb.recordset")
rsw.open "select * from class where num="&rs("class_id"),conn,1,1
k=rsw.recordcount
rsw.close
parCount = k/3 '大块数量
subCount = k mod 3 '剩余零头数量,即最后一个大块中的小块数量
set rsw=server.CreateObject("adodb.recordset")
rsw.open "select * from class where num="&rs("class_id"),conn,1,1
'do while not rsw.eof
for i=0 to parCount-1
content=content&"<div class=""block btm10""><div class=""bl-l""></div><div class=""bl-r""></div>"
for m=0 to 2
content=content&"<div class=""group""><div class=""star""><div class=""st-l""></div><div class=""st-r""></div><div class=""st-c""><h2><span class=""flrgt""><a href=""/class/"&rsw("mz")&".html""><img src=""/image/ico8.gif"" alt="""&rsw("name")&" 更多>>"" title="""&rsw("name")&" 更多>>""/></a></span><a href=""/class/"&rsw("mz")&".html"">"&rsw("name")&"</a></h2><div class=""spec""><div class=""pic""><img src=""/image/pic18.gif""/></div>"
set rss=server.CreateObject("adodb.recordset")
rss.open "select top 1 * from article where class1="&rsw("class_id")&" and tuijian=1 order by article_id desc",conn,1,1
if rss.eof then
content=content&"<p></p><div class=""clear""></div></div>"
else
content=content&"<p><a href=/article/info"&rss("Article_id")&".html title="&rss("title")&">"&left(rss("content"),22)&"</a></p><div class=""clear""></div></div>"
end if
rss.close
set rss=nothing
content=content&"<ul class=""list20"">"
set rsc=server.CreateObject("adodb.recordset")
rsc.open "select top 4 * from article where class1="&rsw("class_id")&" order by article_id desc",conn,1,1
do while not rsc.eof
content=content&"<li>·<a href=/article/info"&rsc("Article_id")&".html title="&rsc("title")&">"&left(rsc("title"),15)&"</a></li>"
rsc.moveNext
loop
content=content&"</ul></div></div></div>"
next
content=content&"</div>"
next
if subCount <>0 then
content=content&"<div class=""block btm10""><div class=""bl-l""></div><div class=""bl-r""></div>"
for i=1 to subCount
content=content&"<div class=""group""><div class=""star""><div class=""st-l""></div><div class=""st-r""></div><div class=""st-c""><h2><span class=""flrgt""><a href=""/class/"&rsw("mz")&".html""><img src=""/image/ico8.gif"" alt="""&rsw("name")&" 更多>>"" title="""&rsw("name")&" 更多>>""/></a></span><a href=""/class/"&rsw("mz")&".html"">"&rsw("name")&"</a></h2><div class=""spec""><div class=""pic""><img src=""/image/pic18.gif""/></div>"
set rss=server.CreateObject("adodb.recordset")
rss.open "select top 1 * from article where class1="&rsw("class_id")&" and tuijian=1 order by article_id desc",conn,1,1
if rss.eof then
content=content&"<p></p><div class=""clear""></div></div>"
else
content=content&"<p><a href=/article/info"&rss("Article_id")&".html title="&rss("title")&">"&left(rss("content"),22)&"</a></p><div class=""clear""></div></div>"
end if
rss.close
set rss=nothing
content=content&"<ul class=""list20"">"
set rsc=server.CreateObject("adodb.recordset")
rsc.open "select top 4 * from article where class1="&rsw("class_id")&" order by article_id desc",conn,1,1
do while not rsc.eof
content=content&"<li>·<a href=/article/info"&rsc("Article_id")&".html title="&rsc("title")&">"&left(rsc("title"),15)&"</a></li>"
rsc.moveNext
loop
content=content&"</ul></div></div></div>"
next
content=content&"</div>"
'rsw.movenext
'loop
end if
麻烦诸位给看看,为什么小版块不能循环呢?谢谢啦……