Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5012259
  • 博文数量: 921
  • 博客积分: 16037
  • 博客等级: 上将
  • 技术积分: 8469
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-05 02:08
文章分类

全部博文(921)

文章存档

2020年(1)

2019年(3)

2018年(3)

2017年(6)

2016年(47)

2015年(72)

2014年(25)

2013年(72)

2012年(125)

2011年(182)

2010年(42)

2009年(14)

2008年(85)

2007年(89)

2006年(155)

分类:

2007-01-09 05:53:28


//////////接收页面变量,并放入数组

//

session_start();

if(!session_is_registered(’stationery’)) session_register(’stationery’);

//清空购物栏

if ($action=="clear") unset($stationery);

//如果是更新购物栏

if ($action=="update" && isset($num_num))

{

for ($c=0;$c<$num_num;$c++)

{

$jj="num".$c;

$stationery[$c][’num’]=$$jj;

}

}

if ($action=="del" && isset($no))

{

$stationery[$no][’id’]="null";

}

if ($action=="order")

{

echo "买单了";

}

if (isset($id))

{

$i=count($stationery);

if($i==0)

{

$stationery[$i][’id’]=$id;

$stationery[$i][’name’]=$name;

$stationery[$i][’price’]=$price;

$stationery[$i][’unit’]=$unit;

$stationery[$i][’num’]=1;

echo "空的购物栏";

}else {

for($j=0;$j<$i;$j++)

{

if($stationery[$j][’id’]==$id)

{

$stationery[$j][’num’]=$stationery[$j][’num’]+1;

break;

}else{

if ($j==($i-1))

{

$stationery[$i][’id’]=$id; //如没有记录,给数组增添一个元素

$stationery[$i][’name’]=$name;

$stationery[$i][’price’]=$price;

$stationery[$i][’unit’]=$unit;

$stationery[$i][’num’]=1; //数量初始化为1

}



}

}

}

reset($stationery);

}

print("您的购物篮现在有已下货品:

");

//购物列表

print ("

name="form2">







");

$s_total=0;

$num_num=0;

for ($a=0;$a
{

$t_id=$stationery[$a][’id’];

$num_num+=1;

if ($t_id!="null")

{

$t_name=$stationery[$a][’name’];

$t_price=$stationery[$a][’price’];

$t_unit=$stationery[$a][’unit’];

$t_num=$stationery[$a][’num’];

$total=$t_num*$t_price;

$h_total+=$total;

print ("
");

print "";

print "";

print "";

print "";

print "";

print ("");

}

}

print ("
数量 型号 价钱 总价 ?/td>
$t_id
maxlength="3">
$t_name¥$t_price¥$total
HEIGHT=17 BORDER=0 ALT="$t_id">
");

print ("











总计费用 ?/td>

¥$h_total
");

print ("
























height="17" border="0" alt="更新购物篮" id="IMAGE1" name="IMAGE1">






border="0" alt="清空购物篮" id="IMAGE2" name="IMAGE2">






height="17" border="0" alt="下定单" id="IMAGE3" name="IMAGE3">

");

?>
阅读(1368) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~