Re: [SMARTY] Newbie Q: was recursive loops, how to do w/Smarty?

From: Date: Wed, 06 Dec 2006 14:30:52 +0000
Subject: Re: [SMARTY] Newbie Q: was recursive loops, how to do w/Smarty?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13616@lists.php.net to get a copy of this message
Use a nested {section} or {foreach} loop in the template. Bjørge Solli wrote:
Hi I'm a beginner at this, but love the concept. Use table sized spoons when answering.. I have something that I normally would code like this: <loop1> SQL-query1 ... <loop2>
    SQL-query2, using the result of SQL-query1 as a part of the query
    ...
</loop2> </loop1> How to do this best with Smarty? The data is ordered something like this: TABLE1: fields: id, info1, info2,... TABLE2: fields: id, table1-ref-id, date, info1, info2,... One entry in TABLE1 has many (thousands) referencing entries in TABLE2. I generally have thousands of entries in TABLE1, each having thousands of entries in TABLE2, so this generates a lot of data to be shown - hence I use the info-fields to select the desired output area. Another small Q: I also use SQL-SELECTs with LIMIT, to limit the size of the page, but I find this to be a part of presentation, not business logic. Is the best way to use .total and .iteration for this? My code looks so much nicer using Smarty, many thanks to all developers!


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