<?php //gouwu.php
session_start();
include "inc/config.php"; //连接数据库的文件
class cart
{
var $cartitem; //存放商品数据
var $count; //商品种数量
var $product_count; //商品数量
var $owner; //用户ID
var $time; //时间
var $orderid; //购物车编
function cart()
{
$this->count=0;
}
#--------------添加商品的函数------------------------#
function add_item($id)
{
global $producttable;//数据库表
$double=0;
for ($i=0;$i<$this->count;$i++)
{
if($this->cartitem[$i]["id"]==$id)
{
$this->cartitem[$i]["product_count"]++;
$double=1;
break;
}
}
if ($double==0){
$sql="select productname,vip_price from $producttable where id=$id";
$sql_query=mysql_query($sql);
$row=mysql_fetch_object($sql_query);
$goodprice=$row->vip_price;
$pname=$row->productname;