sections and associative arrays
| From: | Alexander Gabriel | Date: | Fri, 19 Dec 2003 10:23:31 +0000 |
| Subject: | sections and associative arrays | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-10725@lists.php.net to get a copy of this message | ||
Hi group,
now, i think, i'm on the right list :)
you can see i've got a problem with associative arrays in smarty.
I've tried Andreas' hint, too but it doesn't work. If ID is numeric and
e.g. 50000, Smarty does 50000 loops.
Here are 4 Examples. 1 and 4 are working, 3 is the one with the 50000
loops and the question is, why Example 2 is not working.
[code]
Example 1
<table>
{section name=MyRow loop=$MyValues}
<tr>
<td>{$MyValues[MyRow].ID}: {$MyValues[MyRow].Bezeichnung}
</td>
</tr>
{/section}
</table><br><br>
Example 2
<table>
{section name=MyRow loop=$MyValues}
<tr>
{section name=MyColumn loop=$MyValues[MyRow]}
<td>{$MyValues[MyRow][MyColumn]}</td>
{/section}
</tr>
{/section}
</table><br><br>
Example 3
<table>
{section name=MyRow loop=$MyValues}
<tr>
{section name=MyColumn loop=$MyValues[MyRow].ID}
<td>{$MyValues[MyRow][MyColumn]}</td>
{/section}
</tr>
{/section}
</table><br><br>
Example 4
<table>
{section name=MyRow loop=$MyValues}
<tr>
{foreach item=MyColumn from=$MyValues[MyRow]}
<td>{$MyColumn}</td>
{/foreach}
</tr>
{/section}
</table>
[/code]
It would be very nice, if someone could help me
thx
Alexander Gabriel
>Hi,
>
>This ist the wrong mailing list. Smarty has ist own.
>
>Nevertheless yout second example is not really ok.
>You must set a variable in the loop of the second section (e.g.
>loop=$MyValues[MyRow].ID )
>
>
>Andreas Otterstein
>
>
>-----Ursprüngliche Nachricht-----
>Von: Alexander Gabriel [mailto:alexander.gabriel@blubbermania.com]
>Gesendet: Freitag, 19. Dezember 2003 10:33
>An: pear-general@lists.php.net
>Betreff: [PEAR] sections and associative arrays
>
>
>Hi group,
>
>i've got a problem with an associative array.
>
>if i'm doing:
>
>[code]
><table>
>{section name=MyRow loop=$MyValues}
> <tr>
> <td>{$MyValues[MyRow].ID}:
>{$MyValues[MyRow].Bezeichnung}</td>
> </tr>
>{/section}
></table>
>[/code]
>
>i get a table with the values 'ID' and 'Bezeichnung' from my SQL-result.
>
>
>according to the documentation chapter 7, exapmle 19, this should work
>too:
>
>[code]
><table>
>{section name=MyRow loop=$MyValues}
> <tr>
> {section name=MyColumn loop=$MyValues[MyRow]}
> <td>{$MyValues[MyRow][MyColumn]}</td>
> {/section}
> </tr>
>{/section}
></table>
>[/code]
>
>but all i get is the same table as above but without any values.
>
>I'm new to Smarty and maybe this is just a beginners mistake. would be
>really nice if you could help me.
>
>thx
>Alexander Gabriel
>
>--
>PEAR General Mailing List (http://pear.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php