ASP Simple Shopping Cart Tutorial

Source: Internet
Author: User
Tags include
Shopping Cart | tutorials | Shopping Cart database fields
Table: Pro_talbe:
ID Product number
Proname Product Name
Simages Product Small Picture
Table O_rder:
ID Order number
P_roid Product number
M_um Product Quantity
D_time Order Time
Table co_table:
ID Customer number
Nn_ame Customer Name
Tt_el Contact Tel
Ee_m_ail Customer Email
Index. ASP source

<!--#include file= "connections/conn.asp"-->
Set Recordset1 = Server.CreateObject ("ADODB. Recordset ")
Recordset1.activeconnection = mm_conn_string
Recordset1.source = "SELECT * FROM Pro_table"
Recordset1.cursortype = 0
Recordset1.cursorlocation = 2
Recordset1.locktype = 3 ()
Recordset1_numrows = 0
Dim repeat1__numrows
Repeat1__numrows =-1
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numrows = recordset1_numrows + repeat1__numrows
<title>untitled document</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body bgcolor= "#FFFFFF" text= "#000000" >
<table width= "583" border= "0" cellspacing= "0" cellpadding= "0" >
while ((repeat1__numrows <> 0) and (not recordset1.eof))
&LT;TD width= "140" ><%= (Recordset1.Fields.Item ("id"). Value)%></td>
&LT;TD width= "171" ><%= (Recordset1.Fields.Item ("Proname"). Value)%></td>
&LT;TD width= "272" ><%= (Recordset1.Fields.Item ("Simages"). Value)%></td>
&LT;TD width= "272" ><a href= "cart.asp"? productid=<%= (Recordset1.Fields.Item ("id"). Value)%>&quantity=1 "> Buy </a></td>
Recordset1.movenext ()
Recordset1.close ()
List products, here is a key point is: <a href= "cart.asp?" productid=<%= (Recordset1.Fields.Item ("id"). Value)%>&quantity=1 "> Buy </a>
Two parameters are passed here: Product ID "ProductID" Quantity: "Quantity"

The following is the source code of cart.asp:

<% @LANGUAGE = "VBScript"%>
<!--#include file= "connections/conn.asp"-->
If not IsObject (session ("cart")) Then
Set session ("Cart") =createobject ("Scripting.Dictionary")
End If
Set cart=session ("cart")
PRODUCTID=CSTR (Request ("ProductID"))
Dim detail (1)
Detail (0) =int (Request ("Quantity"))
If Request ("ProductID") <> "then
If cart. Exists (ProductID) Then
Cart. Remove (ProductID)
End If
Cart.add Productid,detail
End If
Set session ("Cart") =cart

<TITLE> Zhejiang guang yuan Printing and Packaging Co., Ltd. </TITLE>
<meta http-equiv=content-type content= "text/html; charset=gb2312 ">
href= "Index/index.css" Type=text/css rel=stylesheet>
<meta content= "MSHTML 5.50.4807.2300" name=generator>
<body text= #000000 bgcolor= #ffffff leftmargin=0 topmargin=0 marginwidth= "0" marginheight= "0" >
<table width= "100%" border= "0" cellspacing= "0" cellpadding= "0" bgcolor= "#FFFFFF" >
&LT;TD width= "100%" valign= "Top" > <br>
<table border= "2" width= "100%" cellspacing= "0" cellpadding= "0" bordercolorlight= "#FFFFFF" bordercolordark= "# FFFFFF "bgcolor=" #D00000 "height=" 1 "align=" Center ">
<tr bgcolor= "#3399FF" >
&LT;TD width= "25%" align= "center" height= "" ><font color= "#FFFFFF" > Product name </font></td>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.