数据库字段
表: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>
<td width="25%" align="center" height="19"><font color="#ffffff">购买数量</font></td>
<td width="12%" align="center" height="19"><font color="#ffffff">更新</font></td>
<td width="13%" align="center" height="19"><font color="#ffffff">删除</font></td>
</tr>
<% for i = 0 to cart.count -1 %>
<% dim list__mmcolparam
list__mmcolparam = keys(i) %>
<% set list = server.createobject("adodb.recordset")
list.activeconnection = mm_conn_string
list.source = "select * from pro_table where id = " + replace(list__mmcolparam, "’", "’’") + ""
list.cursortype = 0
list.cursorlocation = 2
list.locktype = 3
list.open()
%>
<form method="post" action="cart.asp" onsubmit="return checkform(this);"> ’更新产品数量用
<tr bgcolor="#ececff">
<td width="25%" align="center" height="1"><a href="detail.asp?productid=<%=keys(i)%>"><font color="#000077" ></font></a><%=(list.fields.item("proname").value)%></td>
<td width="25%" align="center" height="1">
<input name="quantity" size=4 class="edit" value="<%=items(i)(0)%>">
<input type="hidden" name="productid" value="<%=keys(i)%>">
</td>
<td width="12%" align="center" height="1">
<input type="image" border="0" name="imagefield" src="images/ref.gif" width="17" height="19">
</td>
<td width="13%" align="center" height="1"><a href="delcart.asp?productid=<%=keys(i)%>"><img src="images/del.gif" width="17" height="19" border="0"></a></td>
</tr>
</form>
<%
list.close()
%>
<% next %>
<tr >
<td width="75%" bgcolor="#000000" align="center" height="1" colspan="2">
<p align="right"><font color="#ffffff">总价合计:</font>
</td>
<td width="25%" bgcolor="#000000" align="center" height="1" colspan="2"><font color="#ffffff">¥<%=price%></font></td>
</tr>
</table>
<p align="center"><b><a href="index.asp">继续选购</a> <a href="order.asp">付款</a></b>
</td>
</tr>
</table>
</body>
</html>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器