|
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 |
Piekarz Smarty n00b
Joined: 30 Dec 2010 Posts: 2
|
Posted: Thu Dec 30, 2010 10:33 pm Post subject: foreach doesnt work... |
|
|
Hi, i have a problem with smarty function 'foreach'
I have following code in my .php file:
Code: | $smarty->assign('budynki',$budynki); |
variable $budynki is table with indexes like this:
$budynki[0]['lvl']
$budynki[0]['name']
...
In my style file i have following code (copy from manual):
Code: | <table>
<tr><td></td><td></td></tr>
{foreach $budynki as $b}
{strip}
<tr>
<td>{$b.name}</td>
<td>{$b.lvl}</td>
</tr>
{/strip}
{/foreach}
</table> |
And after run script i see only this message:
Quote: |
Fatal error: Smarty error: [in view_buildings.xhtml line 40]: syntax error: invalid attribute name: '$budynki' (Smarty_Compiler.class.php, line 1550) in D:\wamp\www\inz\smarty\Smarty.class.php on line 1093 |
I found on this forum answer about problem with 'invalid attribute name:' and there was that i should turn off "magic quoutes runtime" in php.ini file, but my php.ini has actualy off - "magic quoutes runtime".
What is more i try to use variable like this:
and its worked!
What i should do now, because i dont have any idea. I really need use foreach function.
I will be really glad if someone help me ;] |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
|
Back to top |
|
Piekarz Smarty n00b
Joined: 30 Dec 2010 Posts: 2
|
Posted: Thu Dec 30, 2010 11:45 pm Post subject: |
|
|
thx you have right ;] |
|
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
|