making a section loop with an assoc. array

From: Date: Wed, 30 May 2001 18:18:34 +0000
Subject: making a section loop with an assoc. array
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-841@lists.php.net to get a copy of this message
Hi all, We are currently testing smarty for phpReview. Most of it is clear to me but I do have some minor probs where I could need some help: Situation: We are using all kinds of classes to handle data. One of them returns an assoc. array from a db.table. The array contains 2 values (id, category). I'm assigning it to smarty like this: $cat = new categories; $catlist = $cat->getAssCatList(); $smarty->assign ('catlist', $catlist) The template where it should get parsed looks like this: {section name=category loop=$catlist} {$catlist[category]}<br> {/section} What happens is that a loop is printed from 0 to count($catlist) and that is my trouble. Since the data could be altered, shifted and could be deleted it will never hold the values from 0 to count($array)... Could anyone give me a solution? Should I pass two arrays to smarty for this? (I don't hope so) or is there some other solution I didn't think of? Regards, Hans -- Linux : http://linux.gelrevision.nl/ phpReview : http://phpReview.nl.linux.org/ Boeken : http://nl.linux.org/boeken/

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