购物网站的购物程序该怎么写?

yuesongboy 2003-10-16 08:38:02
购物网站的购物程序该怎么写?有人能提供加详细注解的代码吗?这里先谢谢了
...全文
133 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuesongboy 2003-10-17
  • 打赏
  • 举报
回复
为什么没人帮我??
yuesongboy 2003-10-17
  • 打赏
  • 举报
回复
以下是我写的购物车程序,可是到后面productlist一直是0不知道为什么,请大家帮我看看

add.asp,添加到购物车中所用程序
<%@language="vbscript"%>
<!--#include file="inc/adovbs.inc"-->
<!--#include file="util.asp"-->
<%
db=server.mappath("data/shop.mdb")
set conn=server.createobject("adodb.connection")
conn.open"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&db
productlist=session("productlist")
products=split(request("productid"),",")
for i=0 to ubound(products)
puttoshopbag products(i),productlist
next
session("productlist")=productlist
response.redirect"cart.asp"
%>

util.asp所引用的
<%
sub puttoshopbag(productid,productlist)
if len(productlist)=0 then
productlist="'"& productid &"'"
elseif instr(productlist,productid)<=0 then
productlist=productlist &",'"&productid&"'"
end if
end sub
%>


cart.asp购物车,这里后面productlist最后一直是0,一直跳到nothin.asp中去
<%@language="vbscript"%>
<!--#include file="inc/adovbs.inc"-->
<!--#include file="util.asp"-->
<%
dbpath=server.mappath("data/shop.mdb")
set conn=server.createobject("adodb.connection")
conn.open"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&dbpath
if request("cmdShow")="yes" then
productlist=""
products=split(request("productid"),",")
for i=0 to ubound(products)
puttoshopbag products(i),productlist
next
session("productlist")=productlist
end if
if len(productlist)=0 then
response.redirect"nothing.asp"
response.end
end if
productlist=session("productlist")
sql="select * from products "
sql=sql & " where productid in("&productlist&")"
sql=sql & " Order By productid"
set rs=conn.execute(sql)
%>

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>

<BODY>
<form action="check.asp"method="post"name=form1>
<table width="97%" border="0">
<tr>
<td height="35" colspan="4" bgcolor="#FFFF00"><strong><font color="#FF0000" size="+3">查看购物车</font></strong></td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
<tr>
<td height="81" colspan="4"> <table width="99%" border="0">
<tr bgcolor="#FFCC99">
<td width="14%"><div align="center">产品编号</div></td>
<td width="27%"><div align="center">产品名称</div></td>
<td width="15%"><div align="center">样式</div></td>
<td width="10%"><div align="center">数量</div></td>
<td width="15%"><div align="center">单价</div></td>
<td width="11%"><div align="center">小计</div></td>
<td width="8%"><div align="center">删除</div></td>
</tr>
<%
sum=0
while not rs.eof
quatity=cint(request("Q_"&rs("productid")))
if quatity<=0 then
quatity=cint(session(rs("productid")))
if quatity<=0 then quatity=1
end if
session(rs("productid"))=quatity
sum=sum+csng(rs("unitcost"))*quatity
sum=formatnumber(sum,2)
%>
<tr bgcolor="#FFFFCC">
<td><div align="center"><%=rs("productid")%></div></div></div></td>
<td><div align="center"><%=rs("modelname")%></div></td>
<td><div align="center"><%=rs("modelnumber")%></div></td>
<td><div align="center">
<input name="<%="Q_"&rs("productid")%>" value="<%=quatity%>"type="text" size="5">
</div></td>
<td><div align="center"><%=rs("unitcost")%></div></td>
<td><div align="center"><%=formatnumber(csng(rs("yhj"))*quatity,2)%></div></td>
<td><div align="center">
<input type="checkbox" name="productid"value="<%=rs("productid")%>">
</div></td>
</tr>
<tr bgcolor="#FFCC99">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
<%rs.movenext
wend%>
<tr>
<td colspan="4">总价:<%=sum%></td>
</tr>
<tr>
<td width="16%"><input name="imageField2" type="image" src="img/update_cart.gif" width="215" height="23" border="0"></td>
<td width="31%"> </td>
<td width="22%"><input name="imageField" type="image" src="img/submit.gif" width="80" height="23" border="0"></td>
<td width="31%"> </td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
</table>
</form>
</BODY>
</HTML>
  • 打赏
  • 举报
回复
用Session数组来保存。我刚学ASP做的第一个程序就是购物的程序。不是很难,慢慢考虑考虑就做好了。
dafei0320 2003-10-17
  • 打赏
  • 举报
回复
购物车是用数组做的!!但是SORRY!!我也没有具体做过!
关注中!!!
yuesongboy 2003-10-16
  • 打赏
  • 举报
回复
我要加注解的!!!!!要很详细的,主要是购物车的那个代码
uiue 2003-10-16
  • 打赏
  • 举报
回复
晕~
自己去下载源码就可以了

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧