1、商品展示页面
table width= 255 border= 0 cellspacing= 0 cellpadding= 0 td width= 130 rowspan= 6 p align= center ?php if(trim($info[tupian]== )) echo 暂无图片 else img src= ?php echo $info[tupian];? width= 130 height= 100 border= 0 ?php /p /td td width= 20 height= 16 /td td width= 113 font color= EF9C3E 【 ?php echo $info[mingcheng];? 】 /font /td /tr td height= 16 /td td font color= 910800 【市场价: ?php echo $info[shichangjia];? 】 /font /td /tr td height= 16 /td td font color= DD4679 【会员价: ?php echo $info[huiyuanjia];? 】 /font /td /tr td height= 16 /td td 【 a href= lookinfo.php?id= ?php echo $info[id];? 查看信息 /a 】 /td /tr td height= 16 /td td 【 a href= addgouwuche.php?id= ?php echo $info[id];? 放入购物车 /a 】 /td /tr td height= 16 /td td font color= 13589B 【剩余数量: ?php if(($info[shuliang]-$info[cishu]) 0) echo ($info[shuliang]-$info[cishu]); else echo 已售完 ? 】 /font /td /tr /table ?php /table
2、文件addgouwuche.php
?phpsession_start();include( conn.php if($_SESSION[username]== ) echo script alert( 请先登录后购物! history.back(); /script exit; $id=strval($_GET[id]);$sql=mysql_query( select * from shangpin where id= .$id. ,$conn); $info=mysql_fetch_array($sql);if($info[shuliang] =0) echo script alert( 该商品已经售完! history.back(); /script exit; $array=explode( @ ,$_SESSION[producelist]); for($i=0;$i count($array)-1;$i++) if($array[$i]==$id) echo script alert( 该商品已经在您的购物车中! history.back(); /script exit; $_SESSION[producelist]=$_SESSION[producelist].$id. @ $_SESSION[quatity]=$_SESSION[quatity]. 1@ header( location:gouwu1.php ?
3、文件gouwu1.php
?php session_start(); if($_SESSION[username]== ) echo script alert( 请先登录,后购物! history.back(); /script exit; ?php include( top.php table width= 800 height= 438 border= 0 align= center cellpadding= 0 cellspacing= 0 td width= 200 height= 438 valign= top bgcolor= #E8E8E8 p align= center ?php include( left.php ? /p /td td width= 10 background= images/line2.gif /td td width= 590 valign= top table width= 550 height= 10 border= 0 align= center cellpadding= 0 cellspacing= 0 td /td /tr /table table width= 500 border= 0 align= center cellpadding= 0 cellspacing= 0 form name= form1 method= post action= gouwu1.php td height= 25 bgcolor= #555555 p align= center >3、文件gouwu2.php
table width= 800 height= 438 border= 0 align= center cellpadding= 0 cellspacing= 0 td width= 200 height= 438 valign= top bgcolor= #E8E8E8 p align= center ?php include( left.php ? /p /td td width= 10 background= images/line2.gif /td td width= 590 valign= top table width= 550 height= 15 border= 0 align= center cellpadding= 0 cellspacing= 0 td /td /tr /table table width= 550 border= 0 align= center cellpadding= 0 cellspacing= 0 td height= 25 bgcolor= #555555 p align= center >4、数据库配置文件conn.php
?php$conn=mysql_connect( localhost , root , ) or die( 数据库服务器连接错误 .mysql_error());mysql_select_db( shop ,$conn) or die( 数据库访问错误 .mysql_error());mysql_query( set character set gb2312 mysql_query( set names gb2312 ?以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP !
相关推荐:
使用PHP实现手机端APP支付宝的支付功能
如何使用php实现快钱支付的功能
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。
新闻热点
疑难解答