ASP簡單購物車教程

來源:互聯網
上載者:User
購物車|教程|購物車 資料庫欄位
  表:pro_talbe:
  id 產品編號
  proname 產品名稱
  simages 產品小圖
  表o_rder:
  id 訂單編號
  p_roid 產品編號
  m_um 產品數量
  d_time 訂購時間
  表co_table:
  id 客戶編碼
  nn_ame 客戶姓名
  tt_el 聯絡電話
  ee_m_ail 客戶郵箱
  +++++++++++++++++++++++
  index.ASP源碼
  +++++++++++++++++++++++
  
  <%@LANGUAGE="VBSCRIPT"%>
  <!--#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.Open()
  Recordset1_numRows = 0
  %>
  <%
  Dim Repeat1__numRows
  Repeat1__numRows = -1
  Dim Repeat1__index
  Repeat1__index = 0
  Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
  %>
  <html>
  <head>
  <title>Untitled Document</title>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
  <table width="583" border="0" cellspacing="0" cellpadding="0">
  <%
  While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
  %>
  <tr>
  <td width="140"><%=(Recordset1.Fields.Item("id").Value)%></td>
  <td width="171"><%=(Recordset1.Fields.Item("proname").Value)%></td>
  <td width="272"><%=(Recordset1.Fields.Item("simages").Value)%></td>
  <td width="272"><a href="cart.asp?ProductID=<%=(Recordset1.Fields.Item("id").Value)%>&quantity=1">購買</a></td>
  </tr>
  <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
  Wend
  %>
  </table>
  </body>
  </html>
  <%
  Recordset1.Close()
  %>
  列出產品,這裡有一個要點就是:<a href="cart.asp?ProductID=<%=(Recordset1.Fields.Item("id").Value)%>&quantity=1">購買</a>
  這裡傳遞了兩個參數:產品ID“ProductID" 數量:“quantity"
  
  +++++++++++++++++++++++++
  下面是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
  keys=cart.keys
  items=cart.items
  set session("cart")=cart
  %>
  
  <HTML>
  <HEAD>
  <TITLE>浙江廣源印刷封裝有限公司</TITLE>
  <META http-equiv=Content-Type content="text/html; charset=gb2312">
  <LINK
  href="index/index.css" type=text/css rel=stylesheet>
  <META content="MSHTML 5.50.4807.2300" name=GENERATOR>
  </HEAD>
  <BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
  <tr>
  <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">
  <td width="25%" align="center" height="19"><font color="#FFFFFF">商品名稱</font></td>
&nbs



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.