购物车里面有10个项目,如何批量提交到数据库保存?

购物车里面有10个项目,如何批量提交到数据库保存?,第1张

订单表和商品表一对多,一个订单多个商品。订单表:ID、订单号、顾客姓名、联系方式、配送地址商品表:ID、订单ID、商品名称、商品价格、商品数量添加的时候先添加一条订单返回mysql_insert_id()做为关联。

终于搞定了。其实也好简单,被数组给恐吓倒了。贴代码,供大家参考吧

dim cbid,mname,mdw,mzk,mnum,mcid

cbid=split(replace(request.Form("cbid")," ",""),",")

mname=split(replace(request.Form("mname")," ",""),",")

mnum=split(replace(request.Form("mnum")," ",""),",")

mdw=split(replace(request.Form("mdw")," ",""),",")

mzk=split(replace(request.Form("mzk")," ",""),",")

mrmb=split(replace(request.Form("mrmb")," ",""),",")

mpaya=split(replace(request.Form("mpaya")," ",""),",")

mcid=request.Form("mcid")

For i=0 To UBound(cbid)

set rs=server.createobject("adodb.recordset")

sql = "SELECT mname,mnum,mdw,mrmb,mrmb2,mzk,mer,mtime,mbz,mcid FROM maichu"

rs.Open sql,conn,1,3

rs.AddNew

rs(0)=mname(i)

rs(1)=mnum(i)

rs(2)=mdw(i)

rs(3)=mrmb(i)

rs(4)=mpaya(i)

rs(5)=mzk(i)

rs(6)=Session("uid")

rs(7)=Now()

rs(8)=request.Form("mbz")

rs(9)=mcid

rs.Update

rs.Close

set rs=nothing

Next


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9597114.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存