网络编程
位置:首页>> 网络编程>> Asp编程>> 一个asp简单购物车教程

一个asp简单购物车教程

  发布时间:2007-09-17 11:02:00 

标签:购物车,asp

asp之家注:如果你学习过asp,并且在网络公司上过班,一定会接触到网购系统,网购系统可以说是一个典型的程序类型,而其中最重要,也是最关键的程序就是:如何处理购物车,以及订单的处理。就我别人来说也做过不少购物系统,有中文也有英文的,而购物车的核心个人觉得就是如何保存购物车的内容。我使用过session,也使用过cookies,这个看客户需求而定,本文介绍了一个asp购物车的系统,相信对刚接触这类程序的人有所帮助!

数据库字段
表: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"

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com