首页 > 编程知识 正文

php产品分类代码(php中函数的分类)

时间:2023-12-18 11:56:34 阅读:316916 作者:XWNV

本文目录一览:

PHP怎么添加二级分类。代码怎么写?

可以做到一个表里面

如下字段 id,parent_id,sort_id,clsid,title,content,orderid,IDS helpids,click,create_time,update_time

如果是顶级分类parent_id就为空,如果是二级分类parent_id就是相应父类的sort_id,如果是三级分类parent_id就是相应二级分类父类的sort_id,这样可以实现无限级分类。

用 thinkphp 做商城 商品分类怎么做? 求代码和建表语句

你好,品牌和类别是2个概率,我建议你建立3个表,goodinfo,brand,category3个表

goodinfo----id,goodname,cid(category表的id),bid(brand表的id)

brand----id,brandname(数据例子:(1,蒙牛),(2,伊利))

category---id,pid,catename(举个例子:(1,0,奶粉),(2,1,1-2岁奶粉),(3,1,2-3岁奶粉),(4,0,饮料))

-----君少

分类统计商品销售量的PHP代码

$starttime = strtotime(date('Y-m-d'));

$endtime = $starttime + 24*3600 -1;

$sql = "select sum(销售数量) as cc from 产品销售表 where times $starttime and times

你可以去后盾人平台看看,里面的东西不错

PHP 商品分类

不用太在意区分父类,与子类

因为父类与子类在同一个表中通过parent_id建立等级的!

点击父类时传递父类本身的ID:product.asp?pid=4

点击子类时也是传递子类本身的ID:product.asp?pid=12

在product.asp页面里通过这个pid查询商品(无论父类或子类)

sql = "select * from goods where pid ="request("pid")

php导航分类代码求助

$query = mysql_query( "SELECT name,id,pid FROM nav WHERE pid = 0 ORDER BY id ASC LIMIT 0 , 8" );

while ( $top = mysql_fetch_array( $query ) ) {

echo $top['name'] . 'br /';

$query2 = mysql_query( "SELECT name,id,pid FROM nav WHERE pid = " . $top["id"] . " ORDER BY id ASC" );

while ( $rs = mysql_fetch_array( $query2 ) ) {

echo '  |____' . $rs['name']. 'br /';

}

}

输出结果:

顶级1

|____顶级1的二级类1

|____顶级1的二级类2

顶级2

|____顶级2的二级类1

|____顶级2的二级类2

顶级3

|____顶级3的二级类1

|____顶级3的二级类2

请 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" /td

td width="590" valign="top"table width="590" height="20" border="0" align="center" cellpadding="0" cellspacing="0"

tr

tddiv align="left" 

?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." /a";

}

while($info=mysql_fetch_object($sql));

}

?

/div/td

/tr

/table

?php

if($_GET[id]=="")

{

$sql=mysql_query("select * from type order by id desc limit 0,1",$conn);

$info=mysql_fetch_array($sql);

$id=$info[id];

}

else

{

$id=$_GET[id];

}

$sql1=mysql_query("select * from type where id=".$id."",$conn);

$info1=mysql_fetch_array($sql1);

$sql=mysql_query("select count(*) as total from shangpin where typeid='".$id."' order by addtime desc ",$conn);

$info=mysql_fetch_array($sql);

$total=$info[total];

if($total==0)

{

echo "div align='center'本站暂无该类产品!/div";

}

else

{

?

table width="550" height="25" border="0" align="center" cellpadding="0" cellspacing="0"

tr

tddiv align="left"span style="color: #666666; font-weight: bold"span style="color: #000000"本类商品/span?php echo $info1[typename];?/span

/div/td

/tr

/table

table width="550" height="10" border="0" align="center" cellpadding="0" cellspacing="0"

tr

td background="images/line1.gif"/td

/tr

/table

table width="550" height="70" border="0" align="center" cellpadding="0" cellspacing="0"

?php

$pagesize=10;

if ($total=$pagesize)

{

$pagecount=1;

}

if(($total%$pagesize)!=0)

{

$pagecount=intval($total/$pagesize)+1;

}

else

{

$pagecount=$total/$pagesize;

}

if(($_GET[page])=="")

{

$page=1;

}

else

{

$page=intval($_GET[page]);

}

$sql1=mysql_query("select * from shangpin where typeid=".$id." order by addtime desc limit ".($page-1) *$pagesize.",$pagesize ",$conn);

while($info1=mysql_fetch_array($sql1)) //显示商品信息

{

?

……

?php

}

?

/table

table width="550" height="25" border="0" align="center" cellpadding="0" cellspacing="0"

tr

tddiv align="right"  本站共有该类商品 

?php

echo $total;

?

 件 每页显示 ?php echo $pagesize;? 件 第 ?php echo $page; ?  页/共 ?php echo $pagecount; ? 页

?php

if($page=2) //商品分页显示

{

?

a href="showfenlei.php?id=?php echo $id;?page=1" title="首页"font face="webdings" 9 /font/a

a href="showfenlei.php?id=?php echo $id;?page=?php echo $page-1;?" title="前一页"font face="webdings" 7 /font/a

?php

}

if($pagecount=4){

for($i=1;$i=$pagecount;$i++){

?

a href="showfenlei.php?id=?php echo $id;?page=?php echo $i;?"?php echo $i;?/a

?php

}

}

else

{

for($i=1;$i=4;$i++){

?

a href="showfenlei.php?id=?php echo $id;?page=?php echo $i;?"?php echo $i;?/a

?php

}

?

a href="showfenlei.php?id=?php echo $id;?page=?php echo $page-1;?" title="后一页"font face="webdings" 8 /font/a

a href="showfenlei.php?id=?php echo $id;?page=?php echo $pagecount;?" title="尾页"font face="webdings" : /font/a

?php

}

?

/div/td

/tr

/table

?php

}

?

/td

/tr

/table

?php

include("bottom.php");

?

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。