主题:这样的循环怎么写,在线等?
[img]http://p15.freep.cn/p.aspx?u=v20_p15_p_0709271513039960_0.gif[/img]
这是自己写的,但好像不是怎么对啊?
<table WIDTH="780" cellpadding="0" cellspacing="0"><tr>
<%dim rs1
sql="select distinct(productclass.id),productclass.cnname,productclass.sortid from productclass,tcgproduct where tcgproduct.classid like '%-'+convert(varchar(255),productclass.id)+'-%' and productclass.parentid=0 order by productclass.sortid"
set rs = server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.Write "还没有商品分类"
else
i=0
do while not rs.eof
if (i mod 2)=0 then bg="#EBEFFF" else bg=""
%>
<TD width="30%" valign="middle" height=25 align= left>
<table width="100%" cellpadding="0" cellspacing="0" >
<tr><td>
<% response.Write "<a href=?catid="&rs("id")&" class=cat_title>"&rs("cnname")&"</a>" %> </td></tr>
<tr><td width="100%" class=table-xia>
<%
sql="select distinct(productclass.id),productclass.cnname,productclass.commend,productclass.sortid from productclass,tcgproduct where tcgproduct.classid like '%-'+convert(varchar(255),productclass.id)+'-%' and productclass.parentid="&rs("id")&" order by productclass.sortid"
set rs1 = server.CreateObject("adodb.recordset")
rs1.open sql,conn,1,1
j=0
do while not rs1.eof
if rs1("commend")>=2 then classname="title" else classname=""
response.Write "<a href=cat.asp?catid="&rs1("id")&" class=smallcat_title><span class="&classname&">"&rs1("cnname")&"</span></a>"
j=j+strlen(rs1("cnname"))+2
if j>55 then
exit do
j=strlen(trim(rs1("cnname")))
end if
rs1.movenext
if not rs1.eof then response.Write("<span class=catline>|</span>")
loop
rs1.close
set rs1 = nothing %>
</TD>
</tr></table></TD>
<%i=i+1
rs.movenext
if (i mod 3)=0 then response.Write("</tr><tr bgcolor="&bg&">")
loop
rs.close
set rs = nothing
end if
%>
</tr>
</table>