|
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 |
neerajmurarka Smarty Rookie
Joined: 15 Aug 2004 Posts: 11
|
Posted: Sun Aug 15, 2004 1:49 am Post subject: Mysql Associatative Result Row in tpl file... |
|
|
Hi People,
I am looping over all the elements in a 2D array, which is basically an array of associative arrays, where each such associatative array is a row from the result of a MySql query.
My problem is... how do I get the value for each element in that row? I am getting errors.
Here is a snippet of the tpl code:
{foreach from=$advertisers item=current_advertiser}
<tr>
<td>{$current_advertiser['name']}</td>
</tr>
{/foreach}
This does not work, and results in:
Fatal error: Smarty error: [in advertisers.tpl line 24]: syntax error: unrecognized tag: $current_advertiser['name'] (Smarty_Compiler.class.php, line 403) in Smarty.class.php on line 1102
If I do the following instead, it works fine, but I do not want to reference my values by index:
{foreach from=$advertisers item=current_advertiser}
<tr>
<td>{$current_advertiser[0]}</td>
</tr>
{/foreach}
I suspect there is some problem with escaping the string or something... any ideas? |
|
Back to top |
|
RoVeRT Smarty n00b
Joined: 17 Mar 2004 Posts: 2
|
Posted: Sun Aug 15, 2004 3:08 am Post subject: |
|
|
this should work {$current_advertiser.name} |
|
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
|