background image

php 电子商务系统:商品分类展示

商品分类展示

设置商品分类显示不仅可使该购物系统的所有商品都分门别类的显示出来,而且为用户
选择商品提供了很大的方便。首先应该建立一个单独的 type 表用来存储商品大类,之后在
shangpin 表中增加一个 typeid 字段,该字段中存储的内容是商品大类 id 值,利用这个值
就可以确定该商品属于那一类。商品分类展示是在 showfenlei.php 中完成的,代码如下:
<!--*******************************showfenlei.php*******************************--

 

<?php

include("top.php");
?>
<table width="800" height="438" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="200" height="438" valign="top" bgcolor="#E8E8E8"><div align="center">
<?php include("left.php");?>
</div></td>
<td width="10" background="images/line2.gif">&nbsp;</td>
<td   width="590"   valign="top"><table   width="590"   height="20"   border="0"   align="center" 
cellpadding="0" cellspacing="0">
<tr>
<td><div align="left">&nbsp;
<?php
$sql=mysql_query("select * from type order by id desc",$conn);
$info=mysql_fetch_object($sql);
if($info==false)
{
echo "本站暂无商品!";
}
else
{
do
{
echo "<a href='showfenlei.php?id=".$info->id."'>".$info->typename."&nbsp;</a>";
}
while($info=mysql_fetch_object($sql));
}
?>
</div></td>
</tr>
</table>
<?php
if($_GET[id]=="")