日期:2014-05-17  浏览次数:20959 次

asp页面循环问题
以下是双重循环,内循环用来控制每行显示多少条记录,外循环用来控制显示多少行,为什么外循环执行一次,就不执行了,没找出原因,请高手指教

VB code

k=1
    for j=0 to countpage-1 step 1
       if rs.recordcount-j*4>4 then
         endfor=4
       else
         endfo=rs.recordcount
       end if
     for i=j*4+1 to endfor
       if k mod 3 = 1 then
          tabl=tabl&"<tr>"
       end if
       tabl=tabl&"<td width=300><table width=281 height=361 border=0 cellpadding=0 cellspacing=0><tr><td valign=top><table width=100% border=0 cellspacing=0 cellpadding=0><tr><td><img src=../admin/Travel/uploadimage/"&rs("photo")&" width=281 height=191 /></td></tr></table><table width=100% border=0 cellpadding=0 cellspacing=10 bgcolor=#fafafa><tr><td><table width=100% border=0 cellspacing=0 cellpadding=0><tr><td height=40 class=huang30>"&rs("TravelName")&rs("id")&"_"&i&"_"&j&countpage&"</td></tr><tr><td class=lan16><table width=100% border=0 cellspacing=0 cellpadding=0><tr><td class=lan14>"&rs("LocationIntroduction")&"</td><td align=right><a href="&rs("TravelName")&".htm target=_blank><img src=../images/more.jpg width=36 height=11 border=0/></a></td></tr></table></td></tr><tr><td height=20><img src=../images/lanxuxian.gif height=1 /></td></tr><tr><td><table width=261 border=0 cellspacing=0 cellpadding=0><tr><td width=70><img src=../images/minpic.gif width=57 height=57 /></td><td valign=top>"&left(rs("TravelIntroduction"),90)&"</td></tr></table></td></tr></table></td></tr></table><table width=100% height=49 border=0 cellpadding=0 cellspacing=0><tr><td align=center background=../images/bg4.gif class=bai16>$<span class=STYLE1>"&rs("TravelPrice")&"</span> | <span class=STYLE1>$TravelTime$</span> | <span class=STYLE1>)</span>hours</td></tr></table></td></tr></table></td>"
    k=k+1
    rs.movenext
    next
    'rs.movenext
    tabl=tabl&"</table></td></tr></table>"
        
    templatecontent=replace(templatecontent,"$title$",title)
    templatecontent=replace(templatecontent,"$keywords$",keyword)

    templatecontent=replace(templatecontent,"$list$",tabl)
    templatecontent=replace(templatecontent,"$Pages$",j&"/"&countpage &pages)
    
    '创建动态生成的页
    set fso=server.createobject("scripting.filesystemobject")
    set htmlwrite=fso.createtextfile(server.mappath("travel/TravelList"&fil&"_"&(j+1)&".htm"),true)
    htmlwrite.writeline templatecontent
    htmlwrite.close
 next



------解决方案--------------------
rs.recordcount 后,rs 指针在 eof 的位置上

把你的 on error resume next 去掉,看看出错的提示
------解决方案--------------------
做分页没必要写两个循环啊。。可以这么写

VBScript code

If Not Rs.eof then
   For i=1 to Rs.pagesize
    Response.write "<td>aaa</td>"
    if (i mod 4) = 0 then Response.write "</tr><tr>" '每4条数据换一行。用表格的话这么处理
    Rs.movenext
   Next
End if