計算筆數的程式
//----------------------------以group by
if(!$class_of_sn==0){
//小類
$sql = "select count(*),class_sn from product group by class_sn";
$result=mysql_db_query(DB_NAME,$sql) or die(mysql_errno(DB_LINK).":".mysql_error(DB_LINK));
while(list($count,$class_sn)=mysql_fetch_row($result)){
$cate_count[$class_sn]=$count;
}
}
//小類
$sql = "select count(*),class_sn from product group by class_sn";
$result=mysql_db_query(DB_NAME,$sql) or die(mysql_errno(DB_LINK).":".mysql_error(DB_LINK));
while(list($count,$class_sn)=mysql_fetch_row($result)){
$cate_count[$class_sn]=$count;
}
}
//-------- mysql_num_rows($result)---------------------------------
if($class_type==0){
$count=chk_pd_count($class_sn);
$count=($count>0)?$count:"";
//$count=(empty($cate_count[$class_sn]))?"":"({$cate_count[$class_sn]})";
}
$count=chk_pd_count($class_sn);
$count=($count>0)?$count:"";
//$count=(empty($cate_count[$class_sn]))?"":"({$cate_count[$class_sn]})";
}
//--------------------------------------------------------------------------------
/-------------- 用類別(小類)檢查產品數量有多少
function chk_pd_count($class_sn=""){
$sql = "select class_sn from product where `class_sn`='{$class_sn}'";
$result=mysql_db_query(DB_NAME,$sql) or die(mysql_errno(DB_LINK).":".mysql_error(DB_LINK));
return mysql_num_rows($result);
}
function chk_pd_count($class_sn=""){
$sql = "select class_sn from product where `class_sn`='{$class_sn}'";
$result=mysql_db_query(DB_NAME,$sql) or die(mysql_errno(DB_LINK).":".mysql_error(DB_LINK));
return mysql_num_rows($result);
}