php - Smarty Template: printing 2 columns in every iteration -
i have php script populates , assing smarty array. want print 2 columns in 1 row start row.
  {section name=customer loop=$custid}     <tr>      // love start loop here loop 2 times      <td>$custid<td>      // , end loop here      </tr>     {/section}      
you can use mod operator current loop index, (not tested) work:
{section name=customer loop=$custid}     {assign var="column" value=$smarty.section.customer.index%2}      {if $column==0}<tr>{/if}     <td>$custid<td>     {if $column==1 || $smarty.section.customer.last}</tr>{/if} {/section}      
Comments
Post a Comment