<?php $tsql2=$empire->query("select * from {$dbtbpre}enewsclass where bclassid='$GLOBALS[navclassid]'"); $i=0; $aex= array(); while($tr=$empire->fetch($tsql2)){ $aaa2=$tr['classid']; $aex[$i]=$aaa2; $i++; }
$chare = implode(",", $aex); ?>
$chare就是所有子栏目ID的函数,直接在灵动标签里使用即可。例如:[e:loop={"select * from www_zzm8_com_ecms_news where classid in ($chare) order by newstime desc limit 1",6,24,0}]
帝国cms内容页获取上级栏目下所有子栏目ID:
<?php $tsql=$empire->query("select * from {$dbtbpre}enewsclass where classid='$GLOBALS[navclassid]'"); while($trs=$empire->fetch($tsql)){ $cllasid=$trs['bclassid']; }
$tsql2=$empire->query("select * from {$dbtbpre}enewsclass where bclassid='$cllasid'"); $i=0; $aex= array(); while($tr=$empire->fetch($tsql2)){ $aaa2=$tr['classid']; $aex[$i]=$aaa2; $i++; }