[Quote=引用 6 楼 wukai0206 的回复:]
bookid=Request.Form("myproduct")
bookid=replace(bookid,", ",",")'去掉空格,得到类似"1,5,9,22,55"这样的产品ID字串
bookid=cint(bookid)?????????????
arr=split(bookid,",")
for i=0 to ubound(arr)
sql="INSERT INTO ceshi (bookid) VALUE ("&arr(i)&")"
conn.execute(sql)
next
for i=0 to ubound(arr)
t=""
t=conn.execute("SELECT 产品ID字段 FROM 表 WHERE 产品ID字段="&arr(i))(0)'看看该产品是否已经存在
if t="" then'不存在就增加1个数量
sql="INSERT INTO 表(产品ID字段,数量字段) VALUE('"&arr(i)&"',1)"
else'否则累加1
sql="UPDATE 表 SET 数量字段=数量字段+1 WHERE 产品ID字段="&arr(i)
end if
conn.execute(sql)
next
%>
bookid=Request.Form("myproduct")
bookid=replace(bookid,", ",",")
bookid=cint(bookid)
arr=split(bookid,",")
for i=0 to ubound(arr)
sql="INSERT INTO ceshi (bookid) VALUE ("&arr(i)&")"
conn.execute(sql)
next
arr=split(bookid,",")
for i=0 to ubound(arr) 't="" ,这个t=""你想说明什么?
set t=conn.execute("SELECT * FROM shop_action WHERE bookid="&arr(i))'看看该产品是否已经存在
if t.eof then'不存在就增加1个数量
sql="insert into shop_action (actionid) values ("&arr(i)&")"
else'否则累加1
sql="UPDATE ceshi SET bookcount=bookcount+1 WHERE id="&arr(i)
end if
conn.execute(sql)
next
师傅 我这样写就对了 谢谢你 但是有个问题没解决 帮个忙
[/Quote]
刚有点时间:(
这两行红字是有意义的(你和我4楼代码比较一下):
t=""'是为了清空这个变量,而这个变量是为了判断是否客户已经选择了这个产品;
t本身是第一个字段的值。你那么一改,变成了记录集了呀
conn.execute("SELECT * FROM shop_action WHERE bookid="&arr(i))(0)相当于rs(0),明白了吗?
我用SELECT *也不好,这样:
t=""
t=conn.execute("SELECT bookid FROM shop_action WHERE bookid="&arr(i))(0)'看看该产品是否已经存在
arr=split(bookid,",")
for i=0 to ubound(arr)
't="" ,这个t=""你想说明什么?
set t=conn.execute("SELECT * FROM shop_action WHERE bookid="&arr(i))'看看该产品是否已经存在
if t.eof then'不存在就增加1个数量
sql="insert into shop_action (actionid) values ("&arr(i)&")"
else'否则累加1
sql="UPDATE ceshi SET bookcount=bookcount+1 WHERE id="&arr(i)
end if
conn.execute(sql)
next
for i=0 to ubound(arr) t=""
t=conn.execute("SELECT 产品ID字段 FROM 表 WHERE 产品ID字段="&arr(i))(0)'看看该产品是否已经存在
if t=""'不存在就增加1个数量
sql="INSERT INTO 表(产品ID字段,数量字段) VALUE('"&arr(i)&"',1)"
else'否则累加1
sql="UPDATE 表 SET 数量字段=数量字段+1 WHERE 产品ID字段="&arr(i)
end if
conn.execute(sql)
next
%>
for i=0 to ubound(arr)
t=conn.execute("SELECT 产品ID字段 FROM 表 WHERE 产品ID字段="&arr(i))(0)'看看该产品是否已经存在
if t=""'不存在就增加1个数量
sql="INSERT INTO 表(产品ID字段,数量字段) VALUE('"&arr(i)&"',1)"
else'否则累加1
sql="UPDATE 表 SET 数量字段=数量字段+1 WHERE 产品ID字段="&arr(i)
end if
conn.execute(sql)
next
%>