asp,购物车问题
<%'添加商品到购物车模块dimshowid,intcount'showid产品IDintcout产品个数showid=request.querystring("Show...
<%
'添加商品到购物车模块
dim showid,intcount 'showid产品ID intcout产品个数
showid = request.querystring("ShowId")
intcount = request.querystring("intcount")
if showid = "" or not isnumeric(showid) then
response.write "<script>alert('非法操作');history.back();</script>"
end if
if intcount = "" or not isnumeric(intcount) then
response.write "<script>alert('非法操作');history.back();</script>"
end if
'开始将产品ID和数量放入购物车
dim productlist,productcount '产品列表变量,产品数量变量
'获取商品列表和数量列表的cookies
productlist = request.cookies("productlist") '商品ID列表 '第一次执行的时候,这个不存在,所以为空
productcount = request.cookies("productcount") '商品数量变量
'split 将一个字符串按照指定的字符分割成数组
dim products,ptcounts
'将产品ID列表和数量列表分割成数组
products = split(productlist,",") 'ID
ptcounts = split(productcount,",") '数量
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
ptcounts(i) = cint(ptcounts(i)) + intcount '累计
response.cookies("productlist") = join(products,",")
response.cookies("productcount") = join(ptcounts,",")
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>金华酥饼行业网站</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<!--#include file="header.asp"-->
<div class="main">
<div id="shopping">
<h3>购物车</h3>
<p>
<%
response.write request.cookies("productlist") & "<br />"
response.write request.cookies("productcount")
%>
</p>
<%
dim rs,sql
set rs = server.CreateObject("adodb.recordset")
sql = "select * from product where P_id in ("&request.cookies("productlist")&")"
rs.open sql,conn,1,1
do while not rs.eof
%>
<table class="cart">
<tr><th>商品编号</th><th>商品名称</th><th>本店价</th><th>数量</th><th>操作</th></tr>
<tr><td><%=prors("P_id")%></td><td><%=prors("P_name")%></td><td><%=prors("P_pri")%></td><td><input type="text" size="3" /></td><td>删除</td></tr>
</table>
<%
rs.movenext
loop
rs.close
set rs = nothing
%>
</div>
</div>
<!--#include file="footer.asp"-->
</body>
</html>
ADODB.Recordset '800a0bb9'
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
\shopping.asp, line 67 展开
'添加商品到购物车模块
dim showid,intcount 'showid产品ID intcout产品个数
showid = request.querystring("ShowId")
intcount = request.querystring("intcount")
if showid = "" or not isnumeric(showid) then
response.write "<script>alert('非法操作');history.back();</script>"
end if
if intcount = "" or not isnumeric(intcount) then
response.write "<script>alert('非法操作');history.back();</script>"
end if
'开始将产品ID和数量放入购物车
dim productlist,productcount '产品列表变量,产品数量变量
'获取商品列表和数量列表的cookies
productlist = request.cookies("productlist") '商品ID列表 '第一次执行的时候,这个不存在,所以为空
productcount = request.cookies("productcount") '商品数量变量
'split 将一个字符串按照指定的字符分割成数组
dim products,ptcounts
'将产品ID列表和数量列表分割成数组
products = split(productlist,",") 'ID
ptcounts = split(productcount,",") '数量
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
ptcounts(i) = cint(ptcounts(i)) + intcount '累计
response.cookies("productlist") = join(products,",")
response.cookies("productcount") = join(ptcounts,",")
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>金华酥饼行业网站</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<!--#include file="header.asp"-->
<div class="main">
<div id="shopping">
<h3>购物车</h3>
<p>
<%
response.write request.cookies("productlist") & "<br />"
response.write request.cookies("productcount")
%>
</p>
<%
dim rs,sql
set rs = server.CreateObject("adodb.recordset")
sql = "select * from product where P_id in ("&request.cookies("productlist")&")"
rs.open sql,conn,1,1
do while not rs.eof
%>
<table class="cart">
<tr><th>商品编号</th><th>商品名称</th><th>本店价</th><th>数量</th><th>操作</th></tr>
<tr><td><%=prors("P_id")%></td><td><%=prors("P_name")%></td><td><%=prors("P_pri")%></td><td><input type="text" size="3" /></td><td>删除</td></tr>
</table>
<%
rs.movenext
loop
rs.close
set rs = nothing
%>
</div>
</div>
<!--#include file="footer.asp"-->
</body>
</html>
ADODB.Recordset '800a0bb9'
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
\shopping.asp, line 67 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询