单数行输出红色 双数行输出绿色 应该怎么写
<table>
{foreach from="$info" item="info" }
<tr style="background:red">
<td><strong>{$info.user_name}<strong></td>
<td><strong>{$info.tel}<strong></td>
</tr>
{/foreach}
</tbody></table>
</table>
第1个回答 推荐于2016-12-01
<table>
{foreach from="$info" item="info" name='in'}
{if $smarty.foreach.in.iteration %2 eq 1}
<tr style="background:red">
{else}
<tr style="background:green">
{/if}
<td><strong>{$info.user_name}<strong></td>
<td><strong>{$info.tel}<strong></td>
</tr>
{/foreach}
</tbody></table>
</table>本回答被提问者采纳
{foreach from="$info" item="info" name='in'}
{if $smarty.foreach.in.iteration %2 eq 1}
<tr style="background:red">
{else}
<tr style="background:green">
{/if}
<td><strong>{$info.user_name}<strong></td>
<td><strong>{$info.tel}<strong></td>
</tr>
{/foreach}
</tbody></table>
</table>本回答被提问者采纳