虽然没用过smarty,不过,我想原理一样的..你在模版里加入一个插代码的地方phplib里是用{}来表示.(smarty里是什么不知道)
然后,你在适合的时候插入</tr><tr>就可以了.讲的有点乱哈

解决方案 »

  1.   

    不用smarty你会写吗?只要不要smarty会写,到了smarty里自然就会了,可以参考smarty手册,具体代码我就不写了,
      

  2.   

    用section、用foreach都可以。再不把数据组织好,一个html_table也就可以了
      

  3.   

    發一個給你研究一下
    php
    <?phprequire "main.php";
     $aaa = array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19");//"33";
     $tpl->assign("aaa",$aaa);
     $tpl->display("for.html");
      
      ?>smtarty
    <table width="96%"  border="1" cellspacing="0" cellpadding="0">
      <tr>
    <{section name=NumIndex loop=$aaa}>
    <td width="25%"> &nbsp;<{$aaa[NumIndex]}>&nbsp;</td>
    <{if (%NumIndex.index%+1) mod 3 == 0 and %NumIndex.index% != 0}></tr><tr bgcolor="#FFFFFF"><{/if}>  <{/section}>
        </tr>
    </table>
      

  4.   

    <{if (%NumIndex.index%+1) mod 3 == 0 and %NumIndex.index% != 0}></tr><tr bgcolor="#FFFFFF"><{/if}>
    在模板里面判断会不会慢,而且又不好控制
      

  5.   

    楼上说到了这个问题,我一直想看看大家一贯的习惯,判断是放在模板里面好呢还是放在php文件里面好呢?
      

  6.   

    已經生成模板了,怎麼會慢呢,按uuq(杜牧)所說,在php里判斷更麻煩.
      

  7.   

    其實都可以實現,你可以在php的數組中,生成一個換行的標籤,也可以在smarty裡面判斷,看你自己的喜好.