Repeated In The Table Smarty + Php
I have a problem in in the table The problem is to repeat I want when it reaches 4 rows to the table is transferred to the new line Code PHP : // for : $tr = 1; while($row = m
Solution 1:
First of all you are reassigning tr in every iteration, and fetching template it outside while loop, so it makes no sense. You should assign variable after fetching all results:
while($row = mysql_fetch_array($post_tv)){
$show[] = $row;
}
$marsosmarty->assign("show", $show);
To move to the next row in table, you can use section name and modulo operator like this:
<td width="91"><table width="100" height="100" border="0" cellpadding="1" cellspacing="1" bgcolor="#666666">
<tbody><tr>
{section name=table loop=$show}
<td bgcolor="#FFFFFF">
<a href="./channel.php?id={$show[table].id}" target="az">
<img src="{$show[table].a_IMG}" alt="{$show[table].a_DESC}" width="100" height="100" border="0" class="link-img" title="{$show[table].a_TITLE}">
</a>
</td>
{if !$smart.section.table.last && $smart.section.table.iteration % 4 eq 0}
</tr><tr>
{/if}
{/section}
</tr>
This way, after displaying 4 cells new table row is created (only if there are more cells, thats ensured by this !$smart.section.table.last
condition)
Post a Comment for "Repeated In The Table Smarty + Php"