1、商品展示页面
复制代码 代码如下:
if(trim($info[tupian]=="")) { echo "暂无图片"; } else { ?> } ?>
|
|
【】 |
|
【市场价:】 |
|
【会员价:】 |
|
【查看信息】 |
|
【放入购物车】 |
|
【剩余数量: if(($info[shuliang]-$info[cishu])>0) { echo ($info[shuliang]-$info[cishu]); } else { echo "已售完"; } ?>】 |
}
?>
2、文件addgouwuche.php
复制代码 代码如下:
session_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] {
echo "<script>alert('该商品已经售完!');history.back();</script>";
exit;
}
$array=explode("@",$_SESSION[producelist]);
for($i=0;$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
复制代码 代码如下:
session_start();
if($_SESSION[username]=="")
{
echo "<script>alert('请先登录,后购物!');history.back();</script>";
exit;
}
?>
include("top.php");
?>
3、文件gouwu2.php
复制代码 代码如下:
if($_GET[dingdanhao]!="")
{ $dd=$_GET[dingdanhao];
session_start();
$array=explode("@",$_SESSION[producelist]);
$sum=count($array)*20+260;
echo" ";
}
?>
4、数据库配置文件conn.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");
?>
http://www.bkjia.com/PHPjc/779566.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/779566.htmlTechArticle1、商品展示页面 复制代码 代码如下: table width="255" border="0" cellspacing="0" cellpadding="0" tr td width="130" rowspan="6"div align="center" ?php if(trim($info[tu...
Stellungnahme:Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn