欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

一个简单的网上书城的例子(四)

程序员文章站 2024-01-30 11:46:46
check.:用户察看所购物品!<%head="以下是您所选购的物品...
check.:用户察看所购物品!

<!--#include file="util.asp" -->

<%
head="以下是您所选购的物品清单"

productlist = session("productlist")
if len(productlist) = 0 then response.redirect "nothing.asp"

dbpath = server.mappath("shopbag.mdb")
set conn = server.createobject("adodb.connection")
conn.open "driver={microsoft access(小型网站之最爱) driver (*.mdb)};dbq=" & dbpath

if request("myself") = "yes" then
   productlist = ""
   products = split(request("productid"), ", ")
   for i=0 to ubound(products)
      puttoshopbag products(i), productlist
   next
   session("productlist") = productlist
   session("first")="no"
end if

sql = "select * from products"
sql = sql & " where productid in (" & productlist & ")"
sql = sql & " order by productid"
set rs = conn.execute( sql )
%>

<html>
<head><title><%=head%></title></head>
<body background="b01.jpg">
<h2 align=center><%=head%></h2>
<center>
<form action=check.asp method=post>
<input type=hidden name=myself value=yes>
<table border=1>
<tr bgcolor=#00ffff>
<td>取消</td><td>书刊编号</td><td>书刊名称</td><td>单价</td><td>数量</td><td>总价</td><td>商品简介</td></tr>
<%
   sum = 0
   c_productid=""
   c_quatity=""
   while not rs.eof
    if session("first")="yes" then
      quatity=1
    else    
     quatity = cint( request( "q_" & rs("productid")) )
     if quatity <= 0 then
        quatity = cint( session(rs("productid")) )
        if quatity<=0 then quatity = 1
     end if
     end if
     session(rs("productid")) = quatity
     sum = sum + cdbl(rs("price")) * quatity
     
    if len(c_productid) = 0 then
       c_productid = "" & rs("productid") & ""
       c_productname = "" & rs("productname") & ""
       c_quatity = "" & quatity & ""
     else
       c_productid =  c_productid & "/" & rs("productid") & ""
       c_productname =  c_productname & "/" & rs("productname") & ""
       c_quatity = c_quatity & "/" &  quatity & ""
     end if     

     
%>
<tr>
<td align=center>
<input type=checkbox name="productid" value="<%=rs("productid")%>" checked>
</td>

<td><%=rs("productid")%></td>
<td><%=rs("productname")%></td>
<td align=right><%=rs("price")%></td>
<td><input type=text name="<%="q_" & rs("productid")%>" value=<%=quatity%> size=3></td>
<td align=right><%=cdbl(rs("price"))*quatity%></td>
<td><a href=<%=rs("link")%>><%=rs("description")%></a></td>
</tr>
<%
      rs.movenext
   wend
%>
<tr><td align=right colspan=7><font color=red>总价格=<%=sum%></font></td></tr>
</table>
<input type=submit value=" 更改数量 ">
</form>
<hr width=80%>
<a href=clear.asp>退回所有物品</a><p>
<% listcategory conn %>
<hr width=80%>
<h2>顾客信息</h2>
<form action=buyfinish.asp method=post>
姓名:<input type=text  name=customer_n value=""><br>
电话:<input type=text  name=customer_t value=""><br>
住址:<input type=text  name=customer_a value=""><br>
<input type=hidden name=customer_p value="<%=c_productid%>">
<input type=hidden name=customer_pn value="<%=c_productname%>">
<input type=hidden name=customer_q value="<%=c_quatity%>">
<input type=hidden name=customer_s value="<%=sum%>">
<input type=submit value=" 提交,完成一次购物. ">
</form><hr width=80%>
</center>

</body>
</html>