//判断ID是否为父类,如果是父类,则返回0,执行下一函数get_child()
function get_Is_parent()
{
$id=$_GET["id"];
$sql="select sum(parent_id) from ecs_category where cat_id=$id ";
$val = intval($GLOBALS['db']->getOne($sql));
return $val;
function get_child()
{
$cat=$_GET['id'];
if ($cat == 0)
{
return array();
}
$arr = $GLOBALS['db']->GetAll('select cat_id from ecs_category where parent_id='.$cat);
if (empty($arr))
{
return array();
}
$cats = array();
$index = 0;
foreach ($arr AS $row)
{
if($index==0)
$c_id.=$row['cat_id'];
$c_id.=",".$row['cat_id'];
$index++;
}
return $c_id;
function get_Is_parent()
{
$id=$_GET["id"];
$sql="select sum(parent_id) from ecs_category where cat_id=$id ";
$val = intval($GLOBALS['db']->getOne($sql));
return $val;
}
function get_child()
{
$cat=$_GET['id'];
if ($cat == 0)
{
return array();
}
$arr = $GLOBALS['db']->GetAll('select cat_id from ecs_category where parent_id='.$cat);
if (empty($arr))
{
return array();
}
$cats = array();
$index = 0;
foreach ($arr AS $row)
{
if($index==0)
$c_id.=$row['cat_id'];
$c_id.=",".$row['cat_id'];
$index++;
}
return $c_id;
}
function hot_category_goods()
{
$id=$_GET['id'];
//判断ID是否为父类
if(get_Is_parent()==0)
{
//ID为父类,则获取父类下的子类
echo "g.cat_id in (".get_child().") and is_hot=1";
}
//ID为子类,执行此代码
else
{
echo "g.cat_id=$id and is_hot=1";
}
}