注册 登录
编程论坛 ASP技术论坛

求助ASP+ACCESS控制显示数据量

longjw 发布于 2008-12-12 11:14, 1089 次点击
在制作网站的过程中,我碰到了这样一个难题
在此请各位大侠赐教
例如我数据库中有9条数据需要显示出来
分别以4条信息为一行
不足4条的单独显示
问题:如何判断所读取的数据等于4
需要的效果:
1234
5678
9
3 回复
#2
jamesxiaoyao2008-12-12 13:51
可以  写个判断,比如 I MOD N 然后输出个换行
#3
孤独冷雨2008-12-12 14:02
<table width="980" border="0" cellspacing="0" cellpadding="0">
     <%
     set rs=server.CreateObject("adodb.recordset")
     sql="select * from yqlj order by id desc"
     rs.open sql,connstr,1,1
      if rs.eof and rs.bof then
          response.Write "<tr><td align='center' height='40'>暂无内容</td></tr>"
          else
          for i=1 to rs.recordcount
     %>
      <tr>
        <td align="left" valign="middle">
        <table width="960" border="0" cellspacing="0" cellpadding="0">
        
          <tr><% for j=1 to 4 %>
            <td width="120" height="44" align="center" valign="middle"><a href="<%=rs("url")%>" target="_blank"><img src="<%=rs("pic")%>" width="88" height="31" border="0" alt="<%=rs("dw")%>" /></a></td>
            <%
          rs.movenext
          if rs.eof then exit for
          next
          
          %>
          </tr>
        
        </table></td>
      </tr>
      <%
      if rs.eof then exit for
            next
            end if
            rs.close
      
      
      %>
    </table>
#4
kira0072008-12-12 15:41
set rs=conn.execute("select username from [user] ")
i=1
do while not rs.eof

if i mod 4=0 then
TXTstr=TXTstr&rs("username")&"<br>"
else
TXTstr=TXTstr&rs("username")&"/"
end if

i=i+1
rs.movenext
loop
rs.close
set rs=nothing

response.write TXTstr
1