 |
|
ช่วยตอบหน่อยเถอะคะ ผู้รู้ทั้งหลาย แก้ไขข้อมูล ในตะกร้าไม่ได้ ยกตัวอย่างนะคะ สินค้า a แก้ไขจำนวนจาก 50 เป็น 100 ปรากฏว่ามันไปเป็น 100 ของ สินค้าอื่น |
|
 |
|
|
 |
 |
|
แก้ไขข้อมูล ในตะกร้าไม่ได้
ยกตัวอย่างนะคะ สินค้า a แก้ไขจำนวนจาก 50 เป็น 100 ปรากฏว่ามันไปเป็น 100 ของ สินค้าอื่น ที่ไม่ใช่ a นะคะ ช่วยดูโค้ดให้ด้วยนะคะ
num=request.Form("num") 'จำนวน 100, 1, 1, 500, 500
eachNum=split(num,", ")
id=request.form("ver") 'รหัส G001, M001, M001, Pb001, Pb001
eachid=Split(id,",")
price=request.form("price") ' ราคา 30, 6000, 6000, 160, 160
eachprice=Split(price,",")
for j=0 to Ubound(eachNum)
ying = eachid(j)
dim rs6,sql6
set rs6 = Server.createObject("ADODB.Recordset")
sql6="select * from shop s,product p where s.sale_id='"&session("sale_id")&"' and s.id ='"& ying &"' and s.id=p.id "
rs6.Open sql6,conn,1,3
if not rs6.eof then
dim rs5,sql5
set rs5 = Server.createObject("ADODB.Recordset")
sql5="select * from shop where sale_id='"&session("sale_id")&"'"
rs5.Open sql5,conn,1,3
if not rs5.eof then
rs5.Fields("num")= eachNum(j)
rs5.Fields("total_price")= eachNum(j) * trim(rs6("price"))
rs5.Update
rs5.MoveNext
rs6.MoveNext
end if
end if
Next
จะกรุณาแก้โค้ดให้ก็จะดีนะคะ
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
7 พ.ย. 2548 15:54:40 |
By :
แกงเลียง |
View :
2164 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เห้อ..ไม่มีใครตอบให้นู๋เลยเหรอ..อ่ะ...วันนี้อารมณ์ดีตอบให้แล้วกันนะ
num=request.Form("num") 'จำนวน 100, 1, 1, 500, 500
eachNum=split(num,", ")
id=request.form("ver") 'รหัส G001, M001, M001, Pb001, Pb001
eachid=Split(id,",")
price=request.form("price") ' ราคา 30, 6000, 6000, 160, 160
eachprice=Split(price,",")
for j=0 to Ubound(eachNum)
ying = eachid(j)
dim rs6,sql6
set rs6 = Server.createObject("ADODB.Recordset")
sql6="select * from shop s,product p where s.sale_id='"&session("sale_id")&"' and s.id ='"& ying &"' and s.id=p.id "
rs6.Open sql6,conn,1,3
if not rs6.eof then 'อาจจะเจอเพียงเรคอร์ดเดียวหรือหลาย ๆ เรคอร์ดก็ได้ในการ join กันของตาราง shop และ product
dim rs5,sql5
set rs5 = Server.createObject("ADODB.Recordset")
'ตรงส่วนนี้น่าจะใช้คำสั่งในการคิวรี่ผิดนะครับ
'sql5="select * from shop where sale_id='"&session("sale_id")&"'"
'คิดว่าน่าจะเป็นแบบนี้นะ
sql5="select * froom shop where sale_id=' "&session("sale_id")&" ' where id=' "&ying&" ' "
rs5.Open sql5,conn,1,3
if not rs5.eof then
for i=0 to rs5.recordcount 'ให้วนลูปเท่ากับจำนวนเรคอร์ดที่ได้จากการคิวรี่
rs5.Fields("num")= eachNum(j)
rs5.Fields("total_price")= eachNum(j) * trim(rs6("price"))
rs5.Update
rs5.MoveNext
next
end if
rs6.MoveNext
Next
end if
'=======ประมาณนี้แหละมั้ง..โชคดีนะจ๊ะ=======
|
 |
 |
 |
 |
Date :
8 พ.ย. 2548 09:48:08 |
By :
นายกระจอก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ว้า...คนแก่ขี้ลืมอีกแย้ววว งั้นเพิ่มเติมอีกนิดนะ
ไม่รู้นู๋ใช้ฐานข้อมูลของอะไร
ถ้าใช้ของ MySQL ก็ให้ทำดังนี้นะจ๊ะ
sql5="select * froom shop where sale_id=' "&session("sale_id")&" ' where id=' "&ying&" ' "
rs.CursorLocation = 3 'อย่าลืมนะตรงส่วนนี้สำคัญมากทีเดียว เพราะว่าจะทำให้ใช้ rs5.RecordCount ไม่ได้ตามความเป็นจริง
rs5.Open sql5,conn,1,3
|
 |
 |
 |
 |
Date :
8 พ.ย. 2548 09:51:27 |
By :
นายกระจอก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณนะคะ พี่นายกระจอก
|
 |
 |
 |
 |
Date :
8 พ.ย. 2548 13:27:39 |
By :
น้องแกงเลียง |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|