亚洲欧美日韩天堂在线观看,日本少妇XXX做受,成人电影在线免费观看,大香蕉在线网站

專業(yè)的廣州網(wǎng)站建設公司、廣州網(wǎng)站設計制作公司為您服務,電話:020-85548809,29883069
新聞中心
專業(yè)專注專心,行業(yè)行情行規(guī)
分享交流,永無止境,我們愿與您共同進步

ASP購物車代碼超級簡單

發(fā)布日期:[2010/10/28]   編輯:奇億廣州網(wǎng)站建設

將以下ASP購物車代碼都保存為一個文件,如cart.asp,調用時比如加入購物車直接使用鏈接cart.asp?id=商品ID即可。本例中商品數(shù)據(jù)庫表為product,使用到商品ID,商品名稱product_name等,在實際使用ASP購物車代碼時將相關參數(shù)替換下。
<%'簡單ASP購物車代碼原理
action=request.QueryString("action")
if request.QueryString("id")="" then
bookid=session("productlist")'//////////////////////////////////調入查詢物品的id
else
  if session("productlist")="" then
session("productlist")=request.QueryString("id")
bookid=request.QueryString("id")
  else
    if instr(request.querystring("id"),session("productlist"))<1 then
bookid=session("productlist")+","+request.QueryString("id")'//////////////把id全部存儲到bookid中類似與數(shù)組
session("productlist")=bookid
    else
bookid=session("productlist")
    end if
  end if
end if

if session("productlist")="" then'////////////////////////若id為空,則說明用戶沒有購物
bookid=0
end if

if action="del" then '刪除購物車中的某一件商品
aProducts=split(Session("ProductList"),",")
delid=cstr(trim(Request.QueryString("id")))
For i=0 To UBound(aProducts)    '循環(huán)所有商品ID
    If trim(aProducts(i))<>delid then
        '不等于被刪除的ID時則保存進新的列表中
        sNewProducts = sNewProducts & "," & aProducts(i)
    end if
Next
Session("ProductList") = mid(sNewProducts,2)
  if session("ProductList")="" then
bookid=0
  else
bookid=Session("ProductList")
  end if
end if
%>

以下是ASP購物車里的所有商品:<br><br>
<%'根據(jù)臨時存儲到SESSION里的商品ID分別從商品數(shù)據(jù)庫循環(huán)調出商品顯示到購物車頁面,遇到重復ID不顯示
if bookid<>0 and bookid<>"" then
set rs=server.CreateObject("adodb.recordset")
dim sql
sql="select id,product_name from product where id in ("&bookid&") order by id" '這里替換成實際的商品數(shù)據(jù)庫及字段
rs.open sql,conn,1,1
   dim bookscount,books '定義判斷有幾個bookid
   bookscount=request.QueryString("id").count
   aa=1
   do while not rs.eof
   dim quatity '判斷input 名
Quatity = CInt( Request( "ckxp"&rs("id")) )
If Quatity <=0 Then Quatity = 1
'以下為購物車每一件商品內(nèi)容,包含ID、名稱、數(shù)量及取消
%>

商品ID:<%=rs("id")%>
商品名稱:<a href="showproduct.asp?id=<%=rs("id")%>" title="<%=rs("info")%>" target="_blank"><%=rs("product_name")%></a>
訂購數(shù)量:<input name="sl<%=aa%>" type="text" Value="1" size="3">
取消商品:<a href="?nav=m&id=<%=rs("id")%>&action=del"><font color="#FF0000" size="4" style="font-weight:bold">×</font></a>
<br>

<%'循環(huán)讀取ASP購物車內(nèi)的商品
rs.movenext
aa=aa+1
loop
rs.close
set rs=nothing
%>
<%if bookid=0 or bookid="" then%>ASP購物車內(nèi)沒有商品,請選擇需訂購的商品。<%end if%>

廣州建網(wǎng)站、廣州做網(wǎng)站
或者將本文《ASP購物車代碼超級簡單》收藏和分享到:
復制本文《ASP購物車代碼超級簡單》地址給好友:
南雄市| 文昌市| 泰安市| 晋州市| 东阳市| 类乌齐县| 盘锦市| 仪征市| 刚察县| 车险| 宜章县| 额济纳旗| 望谟县| 安丘市| 温泉县| 宁远县| 永寿县| 牡丹江市| 开封市| 肥东县| 灵璧县| 伊金霍洛旗| 光泽县| 定兴县| 册亨县| 浦东新区| 姜堰市| 舞阳县| 页游| 鄂州市| 尼勒克县| 项城市| 宝兴县| 永平县| 南江县| 东兴市| 扶绥县| 确山县| 射阳县| 道真| 禹城市|