网页显示源码全是这种循环 
</del> 元</td><td><strong style="color:#f00"></strong> 元</td><td><input type="text" size="3" name="num" value="" /></td><td><a href="shopping.asp?add=ok&del=ok&ShowId=&intcount=">删除</a></td></tr>

<tr><td></td><td></td><td><del></del> 元</td><td><strong style="color:#f00"></strong> 元</td><td><input type="text" size="3" name="num" value="" /></td><td><a href="shopping.asp?add=ok&del=ok&ShowId=&intcount=">删除</a></td></tr>

<tr><td></td><td></td><td><del></del> 元</td><td><strong style="color:#f00"></strong> 元</td><td><input type="text" size="3" name="num" value="" /></td><td><a href="shopping.asp?add=ok&del=ok&ShowId=&intcount=">删除</a></td></tr>

<tr><td></td><td></td><td><del></del> 元</td><td><strong style="color:#f00"></strong> 元</td><td><input type="text" size="3" name="num" value="" /></td><td><a href="shopping.asp?add=ok&del=ok&ShowId=&intcount=">删除</a></td></tr>​显示网页为
服务器源码为
<!--#include file="header.asp"--><%
response.charset = "GBK"

if request.cookies("login")("username") = "" then
call sussLoctionHref("请登陆后购物!","login.asp")
end if

'数量更改
if request.form("send") = "更改数量" then
productcount = request.form("num")
productcount = replace(productcount," ","")

'纠正顺序
ptcounts = split(productcount,",")
ptcountsf = split(productcount,",")
for i = 0 to ubound(ptcounts)
ptcountsf(i) = ptcounts(ubound(ptcounts)-i)
next
productcount = join(ptcountsf,",")

response.cookies("productcount") = productcount & ","
response.redirect "shopping.asp"
end if

'清空购物车模块
if request.querystring("clear") = "ok" then
response.cookies("productlist") = ""
response.cookies("productcount") = ""
response.redirect "shopping.asp"
end if

'添加/删除商品到购物车模块
if request.querystring("add") = "ok" then
dim showid,intcount 'showid产品ID intcout产品个数
showid = request.querystring("ShowId")
intcount = request.querystring("intcount")

if showid = "" or not isnumeric(showid) then
call errorHistoryBack("非法操作!")
end if

if intcount = "" or not isnumeric(intcount) then
call errorHistoryBack("非法操作!")
end if

dim cartrs,cartsql
set cartrs = server.createobject("adodb.recordset")
cartsql = "select * from Mall_Detail where Mall_ID="&showid
cartrs.open cartsql,conn,1,1

if cartrs.eof then
call errorHistoryBack("不存在这个产品!")
end if

cartrs.close
set cartrs = nothing

'开始将产品ID和数量放入购物车

dim i, productlist,productcount '产品列表变量,产品数量变量

'获取商品列表和数量列表的cookies
productlist = request.cookies("productlist")  '商品ID列表 '第一次执行的时候,这个不存在,所以为空
productcount = request.cookies("productcount") '商品数量变量

'split 将一个字符串按照指定的字符分割成数组
dim products,ptcounts

'将产品ID列表和数量列表分割成数组
products = split(productlist,",")   'ID
ptcounts = split(productcount,",") '数量

'防止重复,搜索产品列表,如果没有搜索到同样的产品,那么i就是最大下标
'如果搜索到产品,那么products(i)就是产品的showid

for i = 0 to ubound(products)
if products(i) = showid then exit for 
next

if i > ubound(products) then
'将产品ID和数量写入cookies
response.cookies("productlist") = productlist & showid & ","
response.cookies("productcount") = productcount & intcount & ","
else
'如果购物车里有这个商品,那么就累计他的数量
if request.querystring("del") = "ok" then
ptcounts(i) = 0
products(i) = 0

productlist = join(products,",")
productcount = join(ptcounts,",")

productlist = replace(productlist,"0,","")
productcount = replace(productcount,"0,","")

products = split(productlist,",")
ptcounts = split(productcount,",")
else
ptcounts(i) = cint(ptcounts(i)) + intcount  '累计
end if
response.cookies("productlist") = join(products,",")
response.cookies("productcount") = join(ptcounts,",")
end if

'跳转一下,让地址干净
response.redirect "shopping.asp"
end if
%><div id="sidebar">
<script type="text/javascript" src="js/tag.js"></script>
<div id="sort">
<h1><strong id="nav1">商品分类</strong> / <strong id="nav2">品牌分类</strong></h1>
<div id="navcontent1">
<%
dim navrs,navsql,navrs2,navsql2
set navrs = server.createobject("adodb.recordset")
navsql = "select * from Mall_Nav where Mall_Sid=0 order by Mall_Sort asc"
navrs.open navsql,conn,1,1
do while not navrs.eof
%>
<dl>
<dt><a href="list.asp?showmode=<%=request.cookies("showmode")%>&Classs=navx&ShowId=<%=navrs("Mall_ID")%>"><%=navrs("Mall_NavName")%></a></dt>
<dd>
<%
set navrs2 = server.createobject("adodb.recordset")
navsql2 = "select * from Mall_Nav where Mall_Sid="&navrs("Mall_ID")
navrs2.open navsql2,conn,1,1
do while not navrs2.eof
response.write "<a href='list.asp?showmode="&request.cookies("showmode")&"&Classs=nav&ShowId="&navrs2("Mall_ID")&"'>"&navrs2("Mall_NavName")&"</a> "
navrs2.movenext
loop
navrs2.close
set navrs2 = nothing
%>
</dd>
</dl>
<%
navrs.movenext
loop
navrs.close
set navrs = nothing
%>
</div>
<div id="navcontent2" style="display:none;">
<%
set navrs = server.createobject("adodb.recordset")
navsql = "select * from Mall_Brand where Mall_Sid=0 order by Mall_Sort asc"
navrs.open navsql,conn,1,1
do while not navrs.eof
%>
<dl>
<dt><a href="list.asp?showmode=<%=request.cookies("showmode")%>&Classs=brandx&ShowId=<%=navrs("Mall_ID")%>"><%=navrs("Mall_BrandName")%></a></dt>
<dd>
<%
set navrs2 = server.createobject("adodb.recordset")
navsql2 = "select * from Mall_Brand where Mall_Sid="&navrs("Mall_ID")
navrs2.open navsql2,conn,1,1
do while not navrs2.eof
response.write "<a href='list.asp?showmode="&request.cookies("showmode")&"&Classs=brand&ShowId="&navrs2("Mall_ID")&"'>"&navrs2("Mall_BrandName")&"</a> "
navrs2.movenext
loop
navrs2.close
set navrs2 = nothing
%>
</dd>
</dl>
<%
navrs.movenext
loop
navrs.close
set navrs = nothing
%>
</div>
</div>
<div id="hot">
<h1>人气商品</h1>
<ul>
<%
dim prors,prosql,prohotname
set prors = server.createobject("adodb.recordset")
prosql = "select * from Mall_Detail order by Mall_ProHotCount desc"
prors.open prosql,conn,1,1

for i = 1 to 15
if prors.eof then exit for
prohotname = prors("Mall_ProName")
if len(prohotname) > 12 then
prohotname = left(prohotname,12) & "..."
end if
%>
<li><%=i%>. <a href="detail.asp?ShowId=<%=prors("Mall_ID")%>" target="_blank"><%=prohotname%></a></li>
<%
prors.movenext
next
prors.close
set prors = nothing
%>
</ul>
</div>
<div id="brand">
<h1>品牌推荐</h1>
<%
set sbrs = server.createobject("adodb.recordset")
sbsql = "select * from Mall_sBrand where Mall_Show=1 order by Mall_Date desc"
sbrs.open sbsql,conn,1,1

do while not sbrs.eof
response.write "<img src='"&sbrs("Mall_Logo")&"' alt='"&sbrs("Mall_Name")&"' title='"&sbrs("Mall_Name")&"' />"
sbrs.movenext
loop
%>
</div>
</div><div id="shopping">
<h3>购物车</h3>
<form method="post" action="shopping.asp">
<table class="cart">
<tr><th>商品编号</th><th>商品名称</th><th>市场价</th><th>本店价</th><th>数量</th><th>操作</th></tr>
<%
dim proid,j,pronum,propricetotal1,propricetotal2,numubound

if request.cookies("productcount") = ""  then
proid = 0
else
proid = trim(request.cookies("productlist"))
pronum = split(request.cookies("productcount"),",")
numubound = ubound(pronum) - 1
end if

set prors = server.createobject("adodb.recordset")
prosql = "select * from Mall_Detail where Mall_ID in ("&proid&")"
prors.open prosql,conn,1,1




j = numubound '数组从0开始的,最大下标要减去1
propricetotal1 = 0
propricetotal2 = 0
do while not prors.eof
%>
<tr><td><%=prors("Mall_ID")%></td><td><%=prors("Mall_ProName")%></td><td><del><%=prors("Mall_ProPrice1")%></del> 元</td><td><strong style="color:#f00"><%=prors("Mall_ProPrice2")%></strong> 元</td><td><input type="text" size="3" name="num" value="<%=pronum(j)%>" /></td><td><a href="shopping.asp?add=ok&del=ok&ShowId=<%=prors("Mall_ID")%>&intcount=<%=pronum(j)%>">删除</a></td></tr>
<%
'1表示市场价,2表示本店价
propricetotal1 = propricetotal1 + prors("Mall_ProPrice1") * pronum(j)
propricetotal2 = propricetotal2 + prors("Mall_ProPrice2") * pronum(j)

j = j -1
prors.movenext
loop
%>
<tr><td colspan="6">本店总价:<strong style='color:#f00;font-size:24px;'><%=propricetotal2%></strong> 元 您一共节约了 <strong style='color:#f00;'><%=propricetotal1-propricetotal2%></strong> 元</td></tr>
</table>
<p class="button">
<input type="button" value="继续购物" onclick="javascript:window.close()" />
<input type="submit" value="更改数量" name="send" />
<input type="button" value="清空购物车" onclick="javascript:location.href='shopping.asp?clear=ok'" />
<input type="button" value="下一步" onclick="javascript:location.href='checkout.asp'" />
</p>
</form>
</div><!--#include file="footer.asp"-->

</body>
</html>ASPSQL Server 2005网页循环

解决方案 »

  1.   

               do while not prors.eof                             %>         
    <tr>
      <td><%=prors("Mall_ID")%></td>
      <td><%=prors("Mall_ProName")%></td>
      <td><del><%=prors("Mall_ProPrice1")%></del> 元</td>
      <td><strong style="color:#f00"><%=prors("Mall_ProPrice2")%></strong> 元</td>
      <td><input type="text" size="3" name="num" value="<%=pronum(j)%>" /></td>
      <td><a href="shopping.asp?add=ok&del=ok&ShowId=<%=prors("Mall_ID")%>&intcount=<%=pronum(j)%>">删除</a></td>
    </tr>         
    <%                 
    '1表示市场价,2表示本店价                 
    propricetotal1 = propricetotal1 + prors("Mall_ProPrice1") * pronum(j)                 
    propricetotal2 = propricetotal2 + prors("Mall_ProPrice2") * pronum(j)                                   
    j = j -1                 
    prors.movenext             
    loop         %> 可能是<table class="cart"> 样式把tr改变了
      

  2.   

    这段代码连接access数据库不出现问题,连接sql server 2005之后出现这个问题
      

  3.   

    当把<form method="post" action="shopping.asp">
        <table class="cart">
            <tr><th>商品编号</th><th>商品名称</th><th>市场价</th><th>本店价</th><th>数量</th><th>操作</th></tr>
            <%
                dim proid,j,pronum,propricetotal1,propricetotal2,numubound
                 
                if request.cookies("productcount") = ""  then
                    proid = 0
                else
    里面的if request.cookies("productcount") = ""  then改为 request.cookies("productcount") = where(name is null)显示购物车空一直是0
      

  4.   

    这个样式在连接access中没问题,但是在sql server 2005出现问题,是不是数据库问题??需要怎么理请这个,sql server2005数据库我直接用sql工具导入的,导入过程没有出问题与警告,表的属性中递增改了,其他类型需要改变吗?