Array index variables
| From: | Phillip Smith | Date: | Thu, 09 May 2002 20:05:19 +0000 |
| Subject: | Array index variables | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-4136@lists.php.net to get a copy of this message | ||
I seem to be missing the reason why I can't do the following inside a
template:
{$event_id[$id]}
Where $event_id[] has been populated from a mysql query, and is passed in
as:
$event_id[] .= $data["event_id"];
...
$tpl->assign("event_id",$event_id);
$id in this case is a form variable, say ?id=2, and is passed into the
template with $tpl->assign("id",$id);
In the particular template where this is being used, I am checking to
see if $id is set. If it's not, I use a {section} loop to return all
the values. That works fine. If $id is set, I want to display the values
for just that id.
If I put {$id} in the template somewhere, I get the index number that
I want to pass into {$event_id[]}. When I try it as I have above, I
get "Fatal error: Call to undefined function: ()". What am I overlooking,
can this be done, and what would be a better way?
Thanks.
-phillip