灵动标签无限嵌套方法
<table width="500" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#CC33CC"> <?php $ecms_bq_sql=sys_ReturnEcmsLoopBq('select classid,classname,classpath,wburl from [!db.pre!]enewsclass where bclassid=0 and showclass=0 order by myorder',0,24,0); $bqno=0; while($bqr=$empire->fetch($ecms_bq_sql)) { $bqsr=sys_ReturnEcmsLoopStext($bqr); $classid=($bqr[classid]); $classurl=sys_ReturnBqClassname($bqr,9); $bqno++; ?> <tr> <td><h1><a href="<?=$classurl?>" target="_blank"><?=$bqr[classname]?></a></h1></td> </tr> <?php $ecms_bq_sql2=sys_ReturnEcmsLoopBq("select classid,classname from {$dbtbpre}enewsclass where bclassid=$classid order by myorder,classid asc",0,24,0); $bqno2=0; while($bqr2=$empire->fetch($ecms_bq_sql2)) { $bqsr2=sys_ReturnEcmsLoopStext($bqr2); $classurl=sys_ReturnBqClassname($bqr2,9); $classid2=($bqr2[classid]); $bqno2++; ?> <tr> <td height="54"><h4 style="margin-left:180px;"><a href="<?=$classurl?>" target="_blank"><?=$bqr2[classname]?></a></h4></td> </tr> <tr> <td> [e:loop={$classid2,10,0,0}] <li><a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a> </li> [/e:loop] </td> </tr> <?php } ?> <?php } ?> </table>
不会的把代码拆分看,你会发现所谓的无限嵌套就是在
while($bqr=$empire->fetch($ecms_bq_sql))
里面,再嵌套一个
while($bqr2=$empire->fetch($ecms_bq_sql2))
嵌套多少次就加多少个就行了,照着格式套吧。
本文转载自:精准像素:11px.cn ,感谢作者分享实用知识