来个高手!for循环问题!

kelly_1127 2004-11-10 09:37:05
我想做的是,每一行出三个产品之类的,但是我只能出来两个,高手帮帮忙啊!

<!--#include file="conn.asp" -->
<% set rs= Server.CreateObject("adodb.recordset")
sql="select top 60 * from song order by click desc"
rs.open sql,conn,1,3
response.write rs.recordcount
%>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META><LINK href="images/css.css"
type=text/css rel=stylesheet>
<BODY leftMargin=0 topMargin=0 >
<TABLE width="100%" border=0 cellPadding=1 cellSpacing=1 bgcolor="#e7dfc6">

<TR height=23>
<%if not rs.eof then
for i=1 to rs.recordcount
if rs.eof then
exit for
end if
if i>3 and (i-1) mod 3=0 then
response.write"<tr> "%>
<TD width="33%" bgColor=#f7f7ef><div align="center"><%=rs("name")%>(<A href="http://www.nowok.com/Singer703.htm"><%=rs("player")%>)</A></div></TD>
<%else%>
<TD width="33%" bgColor=#f7f7ef><div align="center"><%=rs("name")%><A href="http://www.nowok.com/Singer703.htm">(<%=rs("player")%>)</A></div></TD>
<TD width="34%" bgColor=#f7f7ef><div align="center"><%=rs("name")%>(<A href="http://www.nowok.com/Singer703.htm"><%=rs("player")%>)
</A></div></TD>
<%end if%>
<%rs.movenext
next%>
<%end if %>
</TR>
</TABLE>
</BODY></HTML>
...全文
105 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
kelly_1127 2004-11-10
  • 打赏
  • 举报
回复
好了
古侠 2004-11-10
  • 打赏
  • 举报
回复
<%if not rs.eof then
for i=1 to rs.recordcount

if i>3 and (i-1) mod 3=0 then

……
%>
<%
next
%>
kelly_1127 2004-11-10
  • 打赏
  • 举报
回复
alern_zyb(alern) 你写的两次都有错
错误类型:
Microsoft VBScript 编译器错误 (0x800A041F)
/music/top60.asp, 第 25 行
next
alern_zyb 2004-11-10
  • 打赏
  • 举报
回复
不好意思,刚才程序有点错误
<TR height=23>
<%i=1
if not rs.eof then
do while not rs.eof %>
<TD width="33%" bgColor=#f7f7ef><div align="center"><%=rs("name")%>(<A href="http://www.nowok.com/Singer703.htm"><%=rs("player")%>)</A></div></TD>

<%if i mod 3=0 then%>
</tr>
<tr height=23>
<%end if%>
<%rs.movenext
loop
next%>
<%end if %>
</TR>
alern_zyb 2004-11-10
  • 打赏
  • 举报
回复
<TR height=23>
<%i=1
if not rs.eof then
do while not rs.eof %>
<TD width="33%" bgColor=#f7f7ef><div align="center"><%=rs("name")%>(<A href="http://www.nowok.com/Singer703.htm"><%=rs("player")%>)</A></div></TD>

<%if i mod 3=0 then%>
</tr>
<tr height=23>
<%end if%>
<%rs.movenext
next%>
<%end if %>
</TR>
zhangxmyf 2004-11-10
  • 打赏
  • 举报
回复
说错了
应该是 先 rs.movenext
再 next
zhangxmyf 2004-11-10
  • 打赏
  • 举报
回复
Do while not rs.eof
for i=1 to 3
这里写要出现的控件
next
rs.movenext
loop
kelly_1127 2004-11-10
  • 打赏
  • 举报
回复
能说清楚点吗?
恶猫 2004-11-10
  • 打赏
  • 举报
回复
for i=1 to rs.recordcount
if i=1 or (i mod 3 = 1) then response.write "<TR>"
response.write "<TD>你想显示的</td>"
if i mod 3 = 0 then response.write "</TR>"
next

  • 打赏
  • 举报
回复
for i=0 to rs.recordcount

28,391

社区成员

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

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