For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > November 2004 > Re: [SMARTY] section and multiple arrays









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] section and multiple arrays
Tng Software

2004-11-15, 8:56 am

Hi,

Woudn't it be better to use the foreach loop for this:

{* smarty *}
{foreach item=customer from=$contacts}
name : {$customer.name}<BR>
home : {$customer.home}<BR>
cell : {$customer.cell}<BR>
e-mail : {$customer.email}<P>
{/foreach}

Guido.

--
TNG Software
van den Hummelstraat 34
5175 CM Loon op Zand
tel. 06-26912345
mail: info@TNGSoftware.nl
web: http://www.tngsoftware.nl


Quoting Valerie Delon <valerie17@gmail.com>:

> Salut!
> I always got error message or even just white browser (without any output
> all) when I use section and associative&multiple arrays since most of the
> example from Manual about section always loop=integer values. (only one
> associative loop=$contacts, not integer but not with PHP code).
>
> What I was trying to do is :
>
> {* smarty *}
> {section name=customer loop=$contacts}
> name : {$contacts[customer].name}<br>
> home : {$contacts[customer].home}<br>
> cell : {$contacts[customer].cell}<br>
> e-mail : {$contacts[customer].email}<p>
> {/section}
>
> -----
>
> <?php
> include 'config3.inc.php';
> $smarty = new Smarty_try;
>
> $name = array('John Smith', 'Jack Jones', 'Jane Munson');
> $home = array('555-555-5555', '666-666-6666', '777-777-7777');
> $cell = array('111-111-1111', '222-222-2222', '333-333-3333');
> $email = array('john@smith.com', 'jack@jones.com', 'jane@munson.net');
>
> $contacts = array($name, $home, $cell, $email);
> // print_r($contacts);die;
>
> $smarty->assign('contacts', $contacts);
> $smarty->display('section3.tpl');
> ?>
>
> and I got trigger error.
>
> Correction to this code above would be very welcome .
>
>
>
> Valérie Delon
> étudiante
>
> --
> On a besoin d'apprendre beacoup plus
> Quelqu'un croit c'est trop
> Mais j'crois que ce n'est pas assez
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com