用asp写的购物车中多个商品数据如何保存到数据库中?看了数组的方法,还是不理解怎么存数据库的。求实例!
表单字段及内容:idnamenumrmb1商品A1件3元5商品B3件60元提交后。用这个:<%response.Writerequest.Form("name")&"<b...
表单字段及内容:
id name num rmb
1 商品A 1件 3元
5 商品B 3件 60元
提交后。用这个:
<%
response.Write request.Form("name")&"<br>"
response.Write request.Form("rmb")&"<br>"
response.Write request.Form("id")&"<br>"
%>
查看获得的数据是这样的:
------------------------
商品A, 商品B
3, 60
1, 5
----------------
怎么把"商品A、3、1"等数据相对应,然后写入数据库里?
看了数组的方法,还是不理解怎么存数据库的。跪求代码实例!
如图~~ 展开
id name num rmb
1 商品A 1件 3元
5 商品B 3件 60元
提交后。用这个:
<%
response.Write request.Form("name")&"<br>"
response.Write request.Form("rmb")&"<br>"
response.Write request.Form("id")&"<br>"
%>
查看获得的数据是这样的:
------------------------
商品A, 商品B
3, 60
1, 5
----------------
怎么把"商品A、3、1"等数据相对应,然后写入数据库里?
看了数组的方法,还是不理解怎么存数据库的。跪求代码实例!
如图~~ 展开
展开全部
其实也好简单,被数组给恐吓倒了。贴代码,供大家参考吧
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询