我想通过在{section name="" loop=""}没4条数据为一行 循环显示,应该如何实现???请教…… 我代码如下
<table>
<tr>
{section name=s loop=$sm_search}
<td>
<table>
<tr>
<td>
<a href="wareDetails.php?id={$sm_search[s].wareid}">
<img src="{$css_dir}{$sm_search[s].imgID}" alt="" />
</a>
</td>
</tr>
<tr>
<td>
{$sm_search[s].warename}
</td>
</tr>
<tr>
<td>
原价:<span style="text-decoration:line-through; font-weight:bold; color:#FF0000;">¥{$sm_search[s].startprice}</span>
</td>
</tr>
<tr>
<td>
售价:¥{$sm_search[s].saleprice}
</td>
</tr>
</table>
</td>
{/section}
</tr>
</table>
<table>
<tr>
{section name=s loop=$sm_search}
<td>
<table>
<tr>
<td>
<a href="wareDetails.php?id={$sm_search[s].wareid}">
<img src="{$css_dir}{$sm_search[s].imgID}" alt="" />
</a>
</td>
</tr>
<tr>
<td>
{$sm_search[s].warename}
</td>
</tr>
<tr>
<td>
原价:<span style="text-decoration:line-through; font-weight:bold; color:#FF0000;">¥{$sm_search[s].startprice}</span>
</td>
</tr>
<tr>
<td>
售价:¥{$sm_search[s].saleprice}
</td>
</tr>
</table>
</td>
{/section}
</tr>
</table>
2.循环的时候你可以定义一个循环变量 当$i%4==0的时候 另起一行
用SMARTY模板区section循环次数 循环次数 %4==0 就换行
<table>
{section name=s loop=$sm_search}
<tr>
<td>
<table>
<tr>
<td>
<a href="wareDetails.php?id={$sm_search[s].wareid}">
<img src="{$css_dir}{$sm_search[s].imgID}" alt="" />
</a>
</td>
</tr>
<tr>
<td>
{$sm_search[s].warename}
</td>
</tr>
<tr>
<td>
原价:<span style="text-decoration:line-through; font-weight:bold; color:#FF0000;">¥{$sm_search[s].startprice}</span>
</td>
</tr>
<tr>
<td>
售价:¥{$sm_search[s].saleprice}
</td>
</tr>
</table>
</td>
{if $smarty.section.customer.rownum eq '4'}
</tr>
{/if}
{/section}
</table>
{section name=s loop=$sm_search}
<tr>
<td>
<table>
<tr>
<td>
<a href="wareDetails.php?id={$sm_search[s].wareid}">
<img src="{$css_dir}{$sm_search[s].imgID}" alt="" />
</a>
</td>
</tr>
<tr>
<td>
{$sm_search[s].warename}
</td>
</tr>
<tr>
<td>
原价:<span style="text-decoration:line-through; font-weight:bold; color:#FF0000;">¥{$sm_search[s].startprice}</span>
</td>
</tr>
<tr>
<td>
售价:¥{$sm_search[s].saleprice}
</td>
</tr>
</table>
</td>
{if $smarty.section.s.rownum eq '4'}
</tr>
{/if}
{/section}
</table>
测试一下看看我多加一个判断{if $smarty.section.s.rownum eq '4'}