problems with looping
| From: | Bill Shupp | Date: | Fri, 19 Dec 2003 20:47:17 +0000 |
| Subject: | problems with looping | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-10730@lists.php.net to get a copy of this message | ||
Hello,
I'm a new Smarty user, and am having problems displaying an associative array within a loop. Here's the section:
{section name=row loop=$out_array}
<tr bgcolor=#eeeeee>
<td><a href="{$out_array[row].edit_url}">{$out_array[row].domain}</td>
<td width=1% nowrap>{$out_array[row].status}</td>
<td width=1% align=middle nowrap>
{if $out_array[row].change_owner_url != ""}
<a href="{$out_array[row].change_owner_url}">{$out_array[row].owner_name}</a>
{else}
{$out_array[row].owner_name}
{/if}
</td>
<td width=1% align=middle nowrap>
{if $out_array[row].change_owner_url != ""}
<a href="{$out_array[row].change_owner_url}">{$out_array[row].group_owner_name}</a>
{else}
{$out_array[row].group_owner_name}
{/if}
</td>
<td width=1% align=middle>
{strip}
{if $out_array[row].status == "active"}
{if $out_array[row].deactivate_url != ""}
<a href="{$out_array[row].deactivate_url}">de-activate</a>
{else}
de-activate
{/if}
{else if $out_array[row].state == "inactive"}
{if $out_array[row].activate_url != ""}
<a href="{$out_array[row].activate_url}">activate</a>
{else}
activate
{/if}
{/if}
{/strip}
</td>
<td align=middle width=1%><a href="{$out_array[row].delete_url}"><img src=images/trash.png border=0></a></td>
</tr>
{/section}
But the problem is that the *first* element of the array does not display values. The table row is there, but everything is blank.
If I just output the array's values to the screen with this:
{foreach from=$out_array item=theValue key=theKey}
{$theKey}:{$theValue}<br>
{foreach from=$theValue item=thenewValue key=thenewKey}
<ul>
<li>{$thenewKey}:{$thenewValue}<br>
</ul>
{/foreach}
{/foreach}
The values are all there, so I'm confident that the array is being built properly, and assigned to Smarty successfully. Any idea why the first row would not display values in the {section} above?
Thanks!!
Regards,
Bill Shupp