| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 771 人关注过本帖
标题:想问一下大家就是关于while嵌套循环的问题
取消只看楼主 加入收藏
fuhuijun
Rank: 1
等 级:新手上路
帖 子:407
专家分:0
注 册:2007-10-30
结帖率:80%
收藏
 问题点数:0 回复次数:1 
想问一下大家就是关于while嵌套循环的问题
大家好,想请教一下大家就是,现在我有两个表先从大类表里面吧大类明先循环查出来,然后在在大类循环里面再从商品表力循环查处等于大类名的记录,但是我做的老是错希望高手指教,下面是我的程序:
      <table width="950" height="5" border="0" cellpadding="0" cellspacing="0">
  <tr>
          <td></td>
        </tr>
      </table>
      <table height="343" cellspacing="0" cellpadding="0" width="950" align="center" border="0">
        <tbody>
          <tr>
            <td width="10" height="343" valign="top">&nbsp;</td>
            <td valign="top" width="224"><!--#include file="left_pinpai.asp"--></td>
            <td valign="top" width="27">&nbsp;</td>
            <td valign="top" width="689"><table cellspacing="0" cellpadding="0" width="689" border="0">
                <tbody>
                  <tr>
                    <td width="689" valign="top"><img height="61" src="images/t_1.gif"
        width="689" /></td>
                  </tr>
                  <tr>
                    <td height="207" align="left" valign="top" bgcolor="#efefef" class="zi"><TABLE width="660" height="148" border=0 align="center" cellPadding=0 cellSpacing=0>
                      <TBODY>
                      <%
                        dim rszhongcai,sqlzhongcai
                        sqlzhongcai="select * from smallclass order by smallclassID desc"
                        set rszhongcai=conn.execute(sqlzhongcai)
                        if rszhongcai.eof or rszhongcai.bof then
                        response.Write("暂时没有记录")
                        
                        else
                        %>

                        <TR>
                    <%
                    i=0
                    do while not rszhongcai.eof
                    i=i+1
                    
                    %>
                          <TD width=647 valign="top"><TABLE width=305 border=0 cellPadding=0 cellSpacing=0 bgcolor="#FFFFFF">
                            <TR>
                              <TD width=6 height=6><IMG height=6
                  src="images/new_box02_top_left.gif"
                  width=6></TD>
                              <TD
                background="images/new_box02_top_bg.gif"><IMG
                  height=1 src="" width=1></TD>
                              <TD width=6 height=6><IMG height=6
                  src="images/new_box02_top_right.gif"
                  width=6></TD>
                            </TR>
                            <TR>
                              <TD width=6
                background="images/new_box02_left_bg.gif"></TD>
                              <TD vAlign=top><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                                  <TBODY>
                                    <TR>
                                      <TD width="9%"
                      background="images/topicbg.gif"
                      bgColor=#ffffff height=25><DIV align=center><IMG height=20
                        src="images/bar1.gif"
                        width=20> </DIV></TD>
                                      <TD class=style4 width="74%"
                      background="images/topicbg.gif"
                      bgColor=#ffffff><B class="g"><%=rszhongcai("smallclassname")%></B> </TD>
                                      <TD width="17%" align="center"
                      background="images/topicbg.gif"
                      bgColor=#ffffff><a href="g4-ny.htm"><IMG
                        src="images/more.gif"
                        width=44 height=11 border="0"></a></TD>
                                    </TR>
                                    <TR>
                                      <TD colSpan=3><IMG height=1 src="" width="100%"></TD>
                                    </TR>
                                    <TR vAlign=top>
                                      <TD colSpan=3><TABLE
                        width="100%" height=70 border=0 cellPadding=0 cellSpacing=0 bgcolor="#FFFFFF">
                                          <TBODY>
                                            <TR>
                                              <TD width="37%"><TABLE cellSpacing=5 cellPadding=0 width="100%"
                              align=center border=0>
                                                  <TBODY>
                                                    <TR vAlign=top>
                                                      <TD align=middle><IMG class=pic3 height=70
                                src="<%=rszhongcai("DefaultPicUrl")%>"
                                width=100
                            border=0></TD>
                                                    </TR>
                                                  </TBODY>
                                              </TABLE></TD>
                                              <TD width="63%" valign="top"><TABLE width="100%" cellPadding=0 cellSpacing=0 class="zi">
                                              <%
                                                  dim rsproduct,sqlproduct
                                                sqlproduct="select * from product where smallclassname="&rszhongcai("smallclassname")
                                                set rsproduct=conn.execute(sqlproduct)
                                            
                                                do while not rsproduct.eof
                                                %>
                                                  <TR>
                                                    <TD width=18 align="center" vAlign=middle class=""><IMG
                                src="images/Photo_common.gif" alt=普通图片 width="7" height="7"></TD>
                                                    <TD width="163" class=""><%=rsproduct("title")%></TD>
                                                  </TR>
                                                  <%
                                                  rsproduct.movenext
                                                  loop
                                                  %>
                                                  
                                              </TABLE></TD>
                                            </TR>
                                          </TBODY>
                                      </TABLE></TD>
                                    </TR>
                                  </TBODY>
                              </TABLE></TD>
                              <TD width=6
                background="images/new_box02_right_bg.gif"></TD>
                            </TR>
                            <TR>
                              <TD><IMG height=6
                  src="images/new_box02_bottom_left.gif"
                  width=6></TD>
                              <TD
                background="images/new_box02_bottom_bg.gif"><IMG
                  height=1 src="" width=1></TD>
                              <TD><IMG height=6
                  src="images/new_box02_bottom_right.gif"
                  width=6></TD>
                            </tr>
                          </TABLE></TD>
                          
                        <%
                            if i mod 2=0 then
                            response.Write("<tr>")
                            end if
                            rszhongcai.movenext
                            loop
                            end if
                            rszhongcai.close
                            set rszhongcai=nothing
                            conn.close
                            set conn=nothing
                        %>
                      </TBODY>
                    </TABLE></td>
                  </tr>
                  
                  <tr>
                    <td valign="top"><img height="11" src="images/company_13.jpg"
            width="689" /></td>
                  </tr>
                </tbody>
            </table></td>
          </tr>
        </tbody>
    </table>
      <table width="950" height="10" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td></td>
        </tr>
      </table>
   <!--#include file="foot.asp"--></td>
  </tr>
</table>
下面是效果:
其中黄字是大类名
灰字是商品表力的信息

未命名.jpg (22.41 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 嵌套 
2008-11-09 16:17
fuhuijun
Rank: 1
等 级:新手上路
帖 子:407
专家分:0
注 册:2007-10-30
收藏
得分:0 
我两个都用的是while循环
2008-11-09 16:18
快速回复:想问一下大家就是关于while嵌套循环的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.078293 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved