蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

[asp]如何让产品展示变成一行两列

代码如下:
<!--#include file="conn.asp"-->
<!--#include file="webconfig.asp"-->
<html><head>
<title><%=webname%>--<%if IsNumeric(request.QueryString("anid"))=False then
                                                                response.write"<script>alert(""输入错误,如有疑问请联系管理员!"");location.href=""index.asp"";</script>"
                                                                response.end
                                                                end if
                                                                if IsNumeric(request.QueryString("nid"))=False then
                                                                response.write"<script>alert(""输入错误,如有疑问请联系管理员!"");location.href=""index.asp"";</script>"
                                                                response.end
                                                                end if
                                        leixing=lcase(trim(request("lx")))
                                          select case leixing
                                          case "big"
                                                  response.write "大类商品"
                                          case "small"
                                                  response.write "小类商品"
                                          case "tejia"
                                                  response.write "特价商品"
                                          case "news"
                                                  response.write "新品上架"
                                          case else
                                                  response.write "新品上架"                                          
                                          end select%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #666666}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onMouseOver="window.status='〖<%=webname%>〗<%=weburl%>如果您喜欢本站,别忘了把本站介绍给您的好友哦!';return false">
<!--#include file="webtop.asp"-->
<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr>
<td width="100%" valign="top" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
<%leixing=lcase(trim(request("lx")))
                                        select case leixing
                                        case "big"
                                        anclassid=request("anid")
                                        set rs=server.createobject("adodb.recordset")
                                        rs.open "select * from shop_anclass where anclassid="&anclassid,conn,1,1
                                        anclassname=rs("anclass")
                                        rs.close
                                        %>
<tr><td colspan="3" background="images/class_bg.jpg" height=50><span class="style1"> <img src="images/ring02.gif" width="23" height="15" align="absmiddle"> <a href=index.asp><%=webname%></a> >> <%=anclassname%></span></td>
</tr>
<%
                                          case "small"
                                                  anclassid=request("anid")
                                                  nclassid=request("nid")
                                                  set rs=server.createobject("adodb.recordset")
                                                  rs.open "select * from shop_anclass where anclassid="&anclassid,conn,1,1
                                                anclassname=rs("anclass")
                                                rs.close
                                                  rs.open "select * from shop_nclass where nclassid="&nclassid,conn,1,1
                                                nclassname=rs("nclass")
                                                rs.close
                                          %>
<tr><td colspan="3" background="images/class_bg.jpg" height=50><span class="style1"> <img src="images/ring02.gif" width="23" height="15" align="absmiddle"> <a href=index.asp><%=webname%></a> >> <a href=class.asp?lx=big&anid=<%=anclassid%>><%=anclassname%></a> >> <%=nclassname%></span></td>
</tr>
<%case "tejia"%>
<tr><td colspan="3" background="images/class_bg.jpg" height=50><span class="style1"> <img src="images/ring02.gif" width="23" height="15" align="absmiddle"> <a href=index.asp><%=webname%></a> >> 特价促销</span></td>
</tr>
<%case "hot"%>
<tr><td colspan="3" background="images/class_bg.jpg" height=50><span class="style1"> <img src="images/ring02.gif" width="23" height="15" align="absmiddle"> <a href=index.asp><%=webname%></a> >> 热卖排行</span></td>
</tr>
<%case "news"%>
<tr><td colspan="3" background="images/class_bg.jpg" height=50><span class="style1"> <img src="images/ring02.gif" width="23" height="15" align="absmiddle"> <a href=index.asp><%=webname%></a> >> 最新上架</span></td>
</tr>
<%case else%>
<tr><td colspan="3" background="images/class_bg.jpg" height=50><span class="style1"> <img src="images/ring02.gif" width="23" height="15" align="absmiddle"> <a href=index.asp><%=webname%></a> >> 最新上架</span></td>
</tr>
<%end select%>
          </table>
                <table width=100% align=center class=table-shang border=0 cellpadding=0 cellspacing=0 bgcolor=#f1f1f1>
                <TR>
                <TD bgColor=#ffffff colSpan=3 height=1></TD>
                <TR>
                <tr>
                <td align=center width=20% height=30><span class="style1">产品预览</span></td>
                <td align=center width=60% height=30><span class="style1">产品名称</span></td>
                <td align=center width=20% height=30><span class="style1">产品价格</span></td>
                </tr>
                <TR>
                <TD bgColor=#cccccc colSpan=3 height=1></TD>
                </TR>
                <TR>
                <TD bgColor=#f1f1f1 colSpan=3 height=3></TD>
                </TR>
                </table>
        <%set rs=server.createobject("adodb.recordset")
                if leixing="big" then
                        rs.open "select * from shop_books where anclassid="&anclassid&" order by adddate desc",conn,1,1
                elseif leixing="small" then
                        rs.open "select * from shop_books where anclassid="&anclassid&" and nclassid="&nclassid&" order by adddate desc",conn,1,1
                elseif leixing="hot" then
                        rs.open "select * from shop_books order by chengjiaocount desc",conn,1,1
                elseif leixing="tejia" then
                        rs.open "select * from shop_books where tejiabook=1 order by adddate desc",conn,1,1
                elseif leixing="news" then
                        rs.open "select * from shop_books where newsbook=1 order by adddate desc",conn,1,1
                else
                        rs.open "select * from shop_books where newsbook=1 order by adddate desc",conn,1,1
                end if
                if rs.recordcount=0 then
                %>
        <table width="370" border="0" cellspacing="0" cellpadding="5" align="center">
        <tr><td align=center>暂无商品</td></tr>
        </table>
        <%
                else
                          rs.PageSize =10 '每页记录条数
                        iCount=rs.RecordCount '记录总数
                        iPageSize=rs.PageSize
                    maxpage=rs.PageCount
                    page=request("page")
   
    if Not IsNumeric(page) or page="" then
        page=1
    else
        page=cint(page)
    end if
   
    if page<1 then
        page=1
    elseif  page>maxpage then
        page=maxpage
    end if
   
    rs.AbsolutePage=Page

        if page=maxpage then
                x=iCount-(maxpage-1)*iPageSize
        else
                x=iPageSize
        end if
       
                        For i=1 To x
                %>
               
<table width="100%" class="table-xia" border="0" cellspacing="0" cellpadding="10" align="center">
<tr>
<td width="20%" rowspan="4" class="table-you" align="center">
<TABLE onmouseover="this.style.backgroundColor='#FF4FAE'" onmouseout="this.style.backgroundColor=''" width=100 height=100 cellSpacing=1 cellPadding=2 bgColor=#e1e1e1 border=0>
<TBODY>
<TR>
<TD width=100 height=100 bgColor=#ffffff align=center>
<%if rs("bookpic")="" then
response.write "<div align=center><a href=list.asp?id="&rs("bookid")&" ><img src=images/emptybook.gif width=90 height=90 border=0></a></div>"
else%>
<a href=list.asp?id=<%=rs("bookid")%> ><img src="<%=trim(rs("bookpic"))%>"  width=100 border=0 height=100></a>
<%end if%>
</td>
</tr>
</tbody>
</table>
</td>
<td width="60%"><img src="images/ring01.gif"> <a href=list.asp?id=<%=rs("bookid")%> ><font color="#ff6600"><u><%=trim(rs("bookname"))%></u></font></a></td>
<td width="20%" rowspan="4" class="table-zuo">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align=center>
<span class="style1">市场价:<s><%=trim(rs("shichangjia"))%> 元</s><br>
会员价:<%=trim(rs("huiyuanjia"))%> 元</span><br>
</td>
</tr>
<tr>
<td align=center>
<a href="gouwu.asp?id=<%=rs("bookid")%>&action=add" target="_blank"><img src="images/goumai.gif" width="65" height="20" border=0></a>
<a href="shoucang.asp?id=<%=rs("bookid")%>&action=add"><img src="images/shoucang1.gif" width="65" height="20" border=0></a>
</td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top"><font color="#666666">
<%if len(trim(rs("bookcontent")))>150 then
        response.write left(trim(rs("bookcontent")),120)&"..."
        else
        response.write trim(rs("bookcontent"))
        end if%></font></td>
</tr>
</table>

        <%rs.movenext
                next
                call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
                end if
                rs.close
                set rs=nothing
Sub PageControl(iCount,pagecount,page,table_style,font_style)
'生成上一页下一页链接
    Dim query, a, x, temp
    action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")

    query = Split(Request.ServerVariables("QUERY_STRING"), "&")
    For Each x In query
        a = Split(x, "=")
        If StrComp(a(0), "page", vbTextCompare) <> 0 Then
            temp = temp & a(0) & "=" & a(1) & "&"
        End If
    Next

    Response.Write("<table width=100% border=0 cellpadding=0 cellspacing=0 bgcolor=#f1f1f1>" & vbCrLf )        
    Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR bgcolor=#f1f1f1>" & vbCrLf )
    Response.Write("<TD align=center height=35>" & vbCrLf )
    Response.Write(font_style & vbCrLf )   
        
    if page<=1 then
        Response.Write ("首 页 " & vbCrLf)        
        Response.Write ("上一页 " & vbCrLf)
    else        
        Response.Write("<A HREF=" & action & "?" & temp & "Page=1>首 页</A> " & vbCrLf)
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page-1) & ">上一页</A> " & vbCrLf)
    end if

    if page>=pagecount then
        Response.Write ("下一页 " & vbCrLf)
        Response.Write ("尾 页 " & vbCrLf)            
    else
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page+1) & ">下一页</A> " & vbCrLf)
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount & ">尾 页</A> " & vbCrLf)            
    end if

    Response.Write(" 页次:" & page & "/" & pageCount & "页" &  vbCrLf)
    Response.Write(" 共有" & iCount & "种商品" &  vbCrLf)
    Response.Write(" 转到" & "<INPUT CLASS=wenbenkuang TYEP=TEXT NAME=page SIZE=2 Maxlength=5 VALUE=" & page & ">" & "页"  & vbCrLf & "<INPUT CLASS=go-wenbenkuang type=submit value=GO>")
    Response.Write("</TD>" & vbCrLf )               
    Response.Write("</TR></form>" & vbCrLf )        
    Response.Write("</table>" & vbCrLf )        
End Sub
%>
</td>
</tr>
</table>
<!--#include file="service.asp"-->
<!--#include file="copyright.asp"-->
</body>
</html>

看错题目鸟。

晕,楼主没有把整站的程序写在上面啊?
....
Response.Write "<table>"
....
Response.Write "<tr>"
for i=1 to 2
Response.Write "<td>"
if not rs.eof then
Response.Write rs("aa")
rs.movenext
else
Response.Write "&nbsp;"
end if
Response.Write "</td>"
exit
Response.Write "</tr>"
....
Response.Write "</table>"

ha ha!我下次一定会的!

建议你把商品展示这块单拿出来做一个页面,
然后展示页面上你想做显示几个商品都行,而且修改起来也比较方便。
例:
<%
sql="select top 8 * from Net008_productlist where newflag='1' and updown='1' order by updatedate desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,2
if rs.recordcount<1 then
response.write"暂无信息!"
'response.end
end if                             
rs.pagesize=8
%>
<table cellpadding=0 width="100%" bgcolor=#FFFFFF border=0 cellspacing="2">
  <tbody>
  <%
dim idx
idx=0
For i = 1 To rs.PageSize/4
idx=idx+1
%>
  <tr valign="top">
      
    <td bgcolor="#FFFFFF" width="25%">
      <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr>
            <td align="center" class="product_title">[<%=rs("productname")%>]</td>
          </tr>
          <tr>
            <td align="center"> <table border="0" cellspacing="1" cellpadding="3" bgcolor="#009933">
                <tr>
                  <td bgcolor="#FFFFFF" align="center"><a href="showproduct.asp?id=<%=rs("id")%>"><img src="<%if rs("imgsize")=0 then%>images/noimageX.gif<%else%>admin/show_productimg.asp?id=<%=rs("id")%><%end if%>" width="100" height="110" border="0" align="absmiddle"></a></td>
                </tr>
              </table></td>
          </tr>
          <tr>
            <td align="center">市 场 价:<s>¥<%=rs("marketprice")%></s>元</td>
          </tr>
          <tr>
            <td align="center"class="title_red">会 员 价:¥<%=rs("newprice")%>元</td>
          </tr>
          <tr>
            <td align="center" class="title_red">V I P 价:¥<%=rs("vipprice")%>元</td>
          </tr>
          <tr>
            
          <td align="center"><a href="shopping.asp?id=<%=rs("id")%>"><img src="images/shopcart.gif" width="74" height="23" border="0" align="absmiddle"></a>[<a href="showproduct.asp?id=<%=rs("id")%>" class="Net008css">详细介绍</a>]</td>
          </tr>
        </table></td>
      <%
        rs.MoveNext  
        If rs.EOF Then Exit For
        %>
      
    <td width="25%" bgcolor="#FFFFFF">
      <table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr>
            <td align="center" class="product_title">[<%=rs("productname")%>]</td>
          </tr>
          <tr>
            <td align="center"> <table border="0" cellspacing="1" cellpadding="3" bgcolor="#009933">
                <tr>
                  <td bgcolor="#FFFFFF" align="center"><a href="showproduct.asp?id=<%=rs("id")%>"><img src="<%if rs("imgsize")=0 then%>images/noimageX.gif<%else%>admin/show_productimg.asp?id=<%=rs("id")%><%end if%>" width="100" height="110" border="0" align="absmiddle"></a></td>
                </tr>
              </table></td>
          </tr>
          <tr>
            <td align="center">市 场 价:<s>¥<%=rs("marketprice")%></s>元</td>
          </tr>
          <tr>
            <td align="center" class="title_red">会 员 价:¥<%=rs("newprice")%>元</td>
          </tr>
          <tr>
            <td align="center" class="title_red">V I P 价:¥<%=rs("vipprice")%>元</td>
          </tr>
          <tr>
            
          <td align="center"><a href="shopping.asp?id=<%=rs("id")%>"><img src="images/shopcart.gif" width="74" height="23" border="0" align="absmiddle"></a>[<a href="showproduct.asp?id=<%=rs("id")%>" class="Net008css">详细介绍</a>]</td>
          </tr>
        </table></td>
      <%
        rs.MoveNext  
        If rs.EOF Then Exit For
        %>
      
    <td width="25%" bgcolor="#FFFFFF">
      <table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr>
            <td align="center" class="product_title">[<%=rs("productname")%>]</td>
          </tr>
          <tr>
            <td align="center"> <table border="0" cellspacing="1" cellpadding="3" bgcolor="#009933">
                <tr>
                  <td bgcolor="#FFFFFF" align="center"><a href="showproduct.asp?id=<%=rs("id")%>"><img src="<%if rs("imgsize")=0 then%>images/noimageX.gif<%else%>admin/show_productimg.asp?id=<%=rs("id")%><%end if%>" width="100" height="110" border="0" align="absmiddle"></a></td>
                </tr>
              </table></td>
          </tr>
          <tr>
            <td align="center">市 场 价:<s>¥<%=rs("marketprice")%></s>元</td>
          </tr>
          <tr>
            <td align="center" class="title_red">会 员 价:¥<%=rs("newprice")%>元</td>
          </tr>
          <tr>
            <td align="center" class="title_red">V I P 价:¥<%=rs("vipprice")%>元</td>
          </tr>
          <tr>
            
          <td align="center"><a href="shopping.asp?id=<%=rs("id")%>"><img src="images/shopcart.gif" width="74" height="23" border="0" align="absmiddle"></a>[<a href="showproduct.asp?id=<%=rs("id")%>" class="Net008css">详细介绍</a>]</td>
          </tr>
        </table></td>
      <%
          rs.MoveNext  
          If rs.EOF Then Exit For  
         %>
      
    <td width="25%" bgcolor="#FFFFFF">
      <table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr>
            <td align="center" class="product_title">[<%=rs("productname")%>]</td>
          </tr>
          <tr>
            <td align="center"> <table border="0" cellspacing="1" cellpadding="3" bgcolor="#009933">
                <tr>
                  <td bgcolor="#FFFFFF" align="center"><a href="showproduct.asp?id=<%=rs("id")%>"><img src="<%if rs("imgsize")=0 then%>images/noimageX.gif<%else%>admin/show_productimg.asp?id=<%=rs("id")%><%end if%>" width="100" height="110" border="0" align="absmiddle"></a></td>
                </tr>
              </table></td>
          </tr>
          <tr>
            <td align="center">市 场 价:<s>¥<%=rs("marketprice")%></s>元</td>
          </tr>
          <tr>
            <td align="center" class="title_red">会 员 价:¥<%=rs("newprice")%>元</td>
          </tr>
          <tr>
            <td align="center" class="title_red">V I P 价:¥<%=rs("vipprice")%>元</td>
          </tr>
          <tr>
            
          <td align="center"><a href="shopping.asp?id=<%=rs("id")%>"><img src="images/shopcart.gif" width="74" height="23" border="0" align="absmiddle"></a>[<a href="showproduct.asp?id=<%=rs("id")%>" class="Net008css">详细介绍</a>]</td>
          </tr>
        </table></td>
      <%
         rs.MoveNext  
         If rs.EOF Then Exit For  
         response.write "<tr><td>&nbsp;</td></tr>"
         next
         %>
    </tr>
  </tbody>
</table>
看看这段对你有没有帮助




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com