recalccart.asp

来自「不错的代码 看完后一定要留评论哦 有疑问联系我」· ASP 代码 · 共 50 行

ASP
50
字号
<%@ LANGUAGE="VBSCRIPT" %>
<!-- #INCLUDE FILE="odbc_connection.inc" -->
<%
on error resume next
'====================
'Add to Shopping Cart
'====================
intSessionID=Session.SessionID

for each item in request.form
	intQuantity=request.form(item)
	strProductID=item

	Set RS = Server.CreateObject("ADODB.Recordset")

	if intQuantity=0 then
		'this Product ID already exists in our cart... change qty
		sSQL="DELETE * FROM tbl_ShoppingCart "
		sSQL=sSQL & "WHERE (s_Item_No='" & strProductID & "' AND intSessionID=" & intSessionID & ")"
	else
		'this Product ID already exists in our cart... change qty
		sSQL="UPDATE tbl_ShoppingCart "
		sSQL=sSQL & "SET tbl_ShoppingCart.intQuantity=" & intQuantity & " "
		sSQL=sSQL & "WHERE (s_Item_No='" & strProductID & "' AND intSessionID=" & intSessionID & ")"
	end if
	RS.Open sSQL, conn , 3, 2 'write
next

'check size of shopping cart
sSQL="SELECT intSessionID, intQuantity "
sSQL=sSQL & "FROM tbl_ShoppingCart "
sSQL=sSQL & "WHERE (intQuantity>0 AND intSessionID=" & intSessionID & ")"
RS.Open sSQL, conn , 3, 3 'read
RS.movelast
Rows=RS.recordcount
RS.close

if Rows>0 then
	'====================
	'move to ShowCart.asp
	'====================
	response.redirect "ShowCart.asp"
else
	'================================================
	'cart empty...go back to inventory.asp
	'================================================
	response.redirect "inventory.asp"
end if
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?