您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 购物网站中的购物车源代码
  所属分类: PHP
  开发工具:
  文件大小: 4kb
  下载次数: 0
  上传时间: 2011-06-06
  提 供 者: lovech******
 详细说明: "; exit; } $mysql_select=mysql_select_db("shopper", $mysql_link); if (!($mysql_select)) { echo "打开数据库失败
"; exit; } /* 购物车 Class */ class Cart { function check_item($table, $session, $product) { $query = "SELECT * FROM $table WHERE session='$session' AND product='$product' "; $result = mysql_query($query); if(!$result) { return 0; } $numRows = mysql_num_rows($result); if($numRows == 0) { return 0; } else { $row = mysql_fetch_object($result); return $row->quantity; } } function add_item($table, $session, $product, $quantity) { $qty = $this->check_item($table, $session, $product); if($qty == 0) { $query = "INSERT INTO $table (session, product, quantity) VALUES "; $query .= "('$session', '$product', '$quantity') "; mysql_query($query); } else { $quantity += $qty; $query = "UPDATE $table SET quantity='$quantity' WHERE session='$session' AND "; $query .= "product='$product' "; mysql_query($query); } } function delete_item($table, $session, $product) { $query = "DELETE FROM $table WHERE session='$session' AND product='$product' "; mysql_query($query); } function modify_quantity($table, $session, $product, $quantity) { $query = "UPDATE $table SET quantity='$quantity' WHERE session='$session' "; $query .= "AND product='$product' "; mysql_query($query); } function clear_cart($table, $session) { $query = "DELETE FROM $table WHERE session='$session' "; mysql_query($query); } function cart_total($table, $session) { $query = "SELECT * FROM $table WHERE session='$session' "; $result = mysql_query($query); if(mysql_num_rows($result) > 0) { while($row = mysql_fetch_object($result)) { $query = "SELECT price FROM inventory WHERE product='$row->product' "; $invResult = mysql_query($query); $row_price = mysql_fetch_object($invResult); $total += ($row_price->price * $row->quantity); } } return $total; } function display_contents($table, $session) { $count = 0; $query = "SELECT * FROM $table WHERE session='$session' ORDER BY id "; $result = mysql_query($query); echo ""; echo ""; echo ""; while($row = mysql_fetch_object($result)) { $query = "SELECT * FROM inventory WHERE product='$row->product' "; $result_inv = mysql_query($query); $row_inventory = mysql_fetch_object($result_inv); $contents["product"][$count] = $row_inventory->product; $contents["price"][$count] = $row_inventory->price; $contents["quantity"][$count] = $row->quantity; $contents["total"][$count] = ($row_inventory->price * $row->quantity); $contents["description"][$count] = $row_inventory->description; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $count++; } echo "
产品编号产品名称单价购买数量单项小计产品描述
".$row_inventory->id."".$row_inventory->product."".$row_inventory->price."".$row->quantity."".$contents["total"][$count]."".$row_inventory->description."
"; $total = $this->cart_total($table, $session); $contents["final"] = $total; return $contents; } function num_items($table, $session) { $query = "SELECT * FROM $table WHERE session='$session' "; $result = mysql_query($query); $num_rows = mysql_num_rows($result); return $num_rows; } function quant_items($table, $session) { $quant = 0; ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: 源代码 购物车 源代码
 输入关键字,在本站1000多万海量源码库中尽情搜索: