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

如何当产品分类到了8种就分列显示呢

雅免 发布于 2012-08-23 23:31, 632 次点击

<%
Dim NoClass2
NoClass2=1
NoClass1=1
Set rs = Server.Createobject("ADODB.recordset")
asql="select  top 20 *   from   BigClass  where  NoClass='"&NoClass2&"'  order by BgOrder asc"
rs.open asql,Cn


%>
<%

if not rs.eof and not rs.bof then
 while not rs.eof
BigClass_Cp=rs("BigClass")
ClassCode_Cp=rs("ClassCode")
  
  Set rs1 = Server.Createobject("ADODB.recordset")
  bsql="select  top 1  *   from   Article  where BigClass='"&ClassCode_Cp&"' and NoClass='"&NoClass1&"'  order by id desc"
  rs1.open bsql,Cn
  if rs1.eof and rs1.bof then
 else
 %>
<div id=CpList01><img src=images/c1.JPG border=0><a  href=<%=Web_WebUrl%><%=ClassCode_Cp%>.html  title='<%=BigClass_Cp%>'><%=BigClass_Cp%></a></div>

<%
  rs1.close   
  set rs1=nothing
  end  if
rs.movenext
wend
rs.close   
set rs=nothing
  
end if
%>
9 回复
#2
雅免2012-08-23 23:35
1  9
2  10
3
4
5
6
7
8
#3
zdloveday2012-08-24 08:51
先得出分类的的种类个数
然后再 if 分类的的种类个数>=8 then
    这里就写入你分列显示的代码
else
这里就写入你不分列显示的代码
end if


#4
雅免2012-08-24 09:06
谢谢楼上,我不懂啊,您能不能就上面的代码修改一下呢?感激不尽!
#5
雅免2012-08-24 22:42
有高手吗?或者直接分两列显示也行。
#6
netlin2012-08-24 23:28
楼主,在你的代码中增加了一些内容,你试试:

<%
if not rs.eof and not rs.bof then
i=1
while not rs.eof
BigClass_Cp=rs("BigClass")
ClassCode_Cp=rs("ClassCode")
  
  Set rs1 = Server.Createobject("ADODB.recordset")
  bsql="select  top 1  *   from   Article  where BigClass='"&ClassCode_Cp&"' and NoClass='"&NoClass1&"'  order by id desc"
  rs1.open bsql,Cn
  if rs1.eof and rs1.bof then
else
%>
if i mod 8=1 then if i=1 then response.write "<table><tr><td>" else response.write "</td><td>"
<div id=CpList01><img src=images/c1.JPG border=0><a  href=<%=Web_WebUrl%><%=ClassCode_Cp%>.html  title='<%=BigClass_Cp%>'><%=BigClass_Cp%></a></div>

<%
i=i+1
  rs1.close   
  set rs1=nothing
  end  if
rs.movenext
wend
rs.close   
set rs=nothing
if i>1 then response.write "</td></tr></table>"
end if
%>
#7
雅免2012-08-25 02:34
代码不行啊,不过还是谢谢netlin斑竹。
只有本站会员才能查看附件,请 登录

我想要这个效果,可惜不行啊。直接分两列显示又如何修改呢?

[ 本帖最后由 雅免 于 2012-8-25 02:41 编辑 ]
#8
netlin2012-08-25 06:36
楼主,如果你原来的代码能运行,你再试试:

<%
if not rs.eof and not rs.bof then
i=1
while not rs.eof
BigClass_Cp=rs("BigClass")
ClassCode_Cp=rs("ClassCode")
  
  Set rs1 = Server.Createobject("ADODB.recordset")
  bsql="select  top 1  *   from   Article  where BigClass='"&ClassCode_Cp&"' and NoClass='"&NoClass1&"'  order by id desc"
  rs1.open bsql,Cn
  if rs1.eof and rs1.bof then
else
%>
if i mod 8=1 then
    if i=1 then
        response.write "<table><tr><td>"
    else
        response.write "</td><td>"
    end if
end if
<div id=CpList01><img src=images/c1.JPG border=0><a  href=<%=Web_WebUrl%><%=ClassCode_Cp%>.html  title='<%=BigClass_Cp%>'><%=BigClass_Cp%></a></div>

<%
i=i+1
  rs1.close   
  set rs1=nothing
  end  if
rs.movenext
wend
rs.close   
set rs=nothing
if i>1 then
    response.write "</td></tr></table>"
end if
end if
%>
#9
雅免2012-08-26 09:56
谢谢netlin老师,您提供的代码还是不行,我的qq:寂寞生存  527081329  加我方便吗?我发源码给您。
#10
雅免2012-08-26 15:39
难啊!加我qq或电邮吧。
1