add_item($productid); ?> " />
麻辣堂|资源主站|开发论坛|在线手册
首页 Apache Linux Java MySQL 注册帮助 
PHP项目开发组是PHP开发资源网于2007组年建成立的项目开发团队,目前核心开发成员有27人, 项目协作成员8名.下设7个开发组,主要承接大/中型网站项目开发任务。

    由于开发任务较多,人员比较紧张,现面向社会招聘全职或者兼职开发人员,不管你是在校大学生,还是全职开发人员,以及SOHO都可以联系本站,我们可以长期合作,并为您带来丰厚的报酬。
  您现在的位置:PHP开发资源网 > 麻辣堂 > 详细资料
待解决
高手来看看,怎么判断这个变量传没传到下页呢?多谢!!
悬赏分:20 - 2007年08月14日

高手来看看,怎么判断这个变量传没传到下页呢?



showproduct.php:
<?
include "cart.php"; //包含购物车类的文件
$cart=new cart;
$cart->add_item($productid); <--------就是这个变量!!!!!!
?>



cart.php:
<?
//本文件是购物车类的定义
class Cart
{
var $cartitem; //此变量用来存放商品数据,实质是二维数组
var $count; //商品种类数量
var $owner; //用户id
var $time; //时间
var $cartid; //购物车编号

//初始化结构函数
function Cart()
{
$this->count=0;
if(isset($userid))
{
$this->owner=$userid;
}
else
{
$this->owner=0;
}
$this->time=date("Y-m-d");
$this->cartid=time();
}

//添加商品的函数
function add_item($productid)
{

if($this->count=0)
{
session_register("$cart");
}

//设定标志变量
$flag="FALSE";
for($i=1;$i<=$this->count;$i++)
{
//检查在购物车里是否已有相同商品
//如果有的话,设定标志为真
//相应的的商品数量加一

if($this->cartitem[$i]["productid"]==$productid)
{
$this->cartitem[$i]["quantity"]++;
$flag="TRUE";
break;
}
}

//如果标志变量为假,说明在购物车里没有相同的商品
//向购物车里面加入商品名,id,价格和数量.
if($flag=="FALSE")
{
$connect=mysql_connect("localhost","Wdwlbsm");
mysql_select_db("ebusiness");
$query="select productid,price,productname from product where productid='$productid'";
$result=mysql_query($query);
$res=mysql_fetch_object($result);
$price=$res->price;
$productname=$res->productname;
$productid=$res->productid;
mysql_close($connect);
$this->count++;
$this->cartitem[$count]["productid"]=$productid;
$this->cartitem[$count]["quantity"]=1;
$this->cartitem[$count]["price"]=$price;
$this->cartitem[$count]["productname"]=$productname;
}
}
?>


我用什么办法能判断showproduct.php里的$productid变量传到了cart.php里呢?多谢!!

提问者:hthc   08-14 09:09
答复
路过。。。顺便帮顶:)
回答者:玉米づ冰冻可乐 - 瓦岗村民 8-22 09:10
我也来回答:
不管你有没有帮助我们,瓦岗寨8万村民将感谢你。。。。。

为防止灌水,您需要计算一道数学题: 答案:
38 + 87 = ? 请将计算结果填在上面

 
[]
©2007 PhpRes.COM