//递归获取下级所有总数
function ListCount($ID,$source)
{
global $dsql,$countall;
$fid = $ID;
$dsql->SetQuery("Select ID,reID,typedir,typename,ispart,sortrank,ishidden From xkzzz_arctype where reID='".$ID."' order by sortrank");
$dsql->Execute($fid);
if($dsql->GetTotalRow($fid)>0)
{
while($row=$dsql->GetObject($fid))
{
$ID = $row->ID;
$ispart = $row->ispart;
//隐藏栏目就跳过,不统计
if($row->ishidden=='1')
continue;
//是列表栏目就进行累加
if($ispart==0)
{
$dsql1=new DedeSql(false);
$row = $dsql1->GetOne("Select count(ID) as dd From xkzzz_archives where typeid='".$ID."' and source='$source' ");
$fcount=$row['dd'];
$countall+=$fcount;
}
else
{
ListCount($ID);
}
}
}
else
{
//是列表栏目就进行累加
if($ispart==0)
{
$dsql1=new DedeSql(false);
$row = $dsql1->GetOne("Select count(ID) as dd From xkzzz_archives where typeid='".$ID."' and source='$source' ");
$fcount=$row['dd'];
$countall+=$fcount;
}
}
}
?>[/post]