|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
rex1982 Smarty Rookie
Joined: 24 Oct 2005 Posts: 28
|
Posted: Sat Nov 12, 2005 3:26 pm Post subject: about the section |
|
|
<table border='1' cellspacing='0' cellpadding='0' align='center' width='300'>
<tr>
{section name=user2 loop=$img}
{ if $smarty.section.user2.rownum % 3 == 0}
<td align='center'><img src='{$img[user2].0}'></td>
{else}
</tr>
<tr>
<td align='center'><img src='{$img[user2].0}'></td>
{/if}
{/section}
</tr>
</table>
i wanna output three records per row
how i do it......
Thx... |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Sun Nov 13, 2005 11:49 am Post subject: |
|
|
In my opinion you should prepare your array with the structure and use 2 loops...
Pseudocode:
[php:1:b182732921]
Array(
0 => Array(
0=> Array( *Record1*)
1=> Array( *Record2*)
2=> Array( *Record3*)
)
1 => Array(
0=> Array( *Record4*)
1=> Array( *Record5*)
2=> Array( *Record6*)
)
2 => Array(
0=> Array( *Record7*)
1=> Array( *Record8*)
2=> Array( *Record9*)
)
)
[/php:1:b182732921]
Template:
[php:1:b182732921]
{foreach name=outer item=row from=$result}
{foreach item=col from=$row}
{$col}<br />
{/foreach}
{/foreach}
[/php:1:b182732921]
Bye,
Markus |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sun Nov 13, 2005 4:09 pm Post subject: |
|
|
the FAQ in the wiki has examples of multi-column/row output. also see {html_table} |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|