I'm using the smarty template engine for a project, but I ran into difficulties when I tried to assign to smarty multiple associative arrays:
I retrieve from a db the following fields, for each row returned ($i being the number of the row):
$customer[$i][$name];
$customer[$i][$address];
$customer[$i][$telephone];
I can't understand how to pass those values to smarty, and how to loop through them in a template.
I mean: how can I tell smarty to use the variable $i to loop through the array?
I had no problem when there was only one row returned from the db, and this was what I did (with success):
//The fields from the db are stored here:
$customer[$name];
$customer[$address];
$customer[$telephone];
//here a loop to assign
while (list ($key, $value) = each ($customer))
{
$smarty->assign($key,$value);
}
//then, in the template I just echoed those values...
{$name}, {$address}, {$telephone}