Re: [SMARTY] Simple table from array

From: Date: Thu, 23 Oct 2003 23:57:01 +0000
Subject: Re: [SMARTY] Simple table from array
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10412@lists.php.net to get a copy of this message
Wilmar... I would use the {section} tags to work with multidimesional arrays.. for your example.. <table width="100%" border="0" cellspacing="0"> {section name=code loop=$topic} <tr> <td><a href="code{$topic[code].topic_code}">{$topic[code].topic_name}</a></td> </tr> {/section} </table> This is how I normally work with multidimensional arrays, and works perfectly every time.. Rolf Brusletto http://www.phpExamples.net Wilmar Perez wrote:
Hello everyone I've got the following: $smarty->assign('topic',array( array('topic_code' => '1', 'topic_name' => 'name1'), array('topic_code' => '2', 'topic_name' => 'name2'), array('topic_code' => '3', 'topic_name' => 'name3'), array('topic_code' => '4', 'topic_name' => 'name4') ) ); And I want to get this result: <table width="100%" border="0" cellspacing="0"> <tr> <td><a href="code1">name1</a></td> </tr> <tr> <td><a href="code2">name2</a></td> </tr> <tr> <td><a href="code3">name3</a></td> </tr> <tr> <td><a href="code4">name4</a></td> </tr> </table> I've tried this (as shown in the manual). I know it doesn't add the link, I'll work it out later on: {foreach name=outer item=topic from=$topic} {foreach key=key item=item from=$topic} {$key}:{$item}<br> {/foreach} {/foreach} But keep getting this: 0:Array 1:Array 2:Array 3:Array 0:Array 1:Array 2:Array 3:Array 0:Array 1:Array 2:Array 3:Array 0:Array 1:Array 2:Array 3:Array So, does anyone have any idea of what I'm doing wrong? Thanks a lot. *******************************************************
                        Wilmar Pérez
                    Network Administrator
                      Library System
                     Tel: ++57(4)2105962
                   University of Antioquia
                      Medellín - Colombia
                             2002    *******************************************************


« previous php.smarty.general (#10412) next »