Re: [SMARTY] Newbie Q: was recursive loops, how to do w/Smarty?
Bjørge Solli <[email protected]> Thu, 7 Dec 2006 17:47:18 +0100
| Newsgroups | gmane.comp.php.smarty.general |
|---|---|
| Message-ID | <[email protected]> |
Thanks, I learned a lot when I knew what to look for. But one question
remains, and this is something I don't understand after reading countless
examples;
My table looks like this:
Array
(
[1066] => Array
(
[0] => Array
(
[msal] => 34.53955
[osal] => 35.479
[otemp] => 18.112
[mtemp] => 11.60205
[pressure] => 5
)
[1] => Array
(
[msal] => 34.54223
[osal] => 35.474
[otemp] => 18.119
[mtemp] => 11.58791
[pressure] => 16
)
[2] => Array
(
[msal] => 34.54327
[osal] => 35.474
[otemp] => 18.123
[mtemp] => 11.57551
[pressure] => 25
)
[3] => Array
(
[msal] => 34.54379
[osal] => 35.475
[otemp] => 18.096
[mtemp] => 11.54656
[pressure] => 35
)
...
It is made using this:
$smarty->assign('data',$db->getAssoc($query, true, null, DB_FETCHMODE_ASSOC,
true));
But when I try this template it doesn't return anything:
{foreach item=point key=key from=$points name=Point}
<print some stuff from point; it works>
...
{foreach item=comp from=$data[$key]}
<tr class="{cycle values="oddrow,evenrow"}">
<td>{$comp.pressure}</td>
<td {if abs($comp.osal - $comp.msal) gt $Dsal}
bgcolor="yellow"{/if}>{$comp.osal}</td>
<td>{$comp.msal}</td>
<td {if abs($comp.otemp - $comp.mtemp) gt $Dtemp}
bgcolor="yellow"{/if}>{$comp.otemp}</td>
<td>{$comp.mtemp}</td>
</tr>
{foreachelse}
<tr><td colspan="5">No data found</td></tr>
{/foreach}
...
{/foreach}
The outer foreach works fine, but the inner one reaches the foreachelse-part
(empty table).
I think there might be something wrong with the from= or I am using the table
wrong.
I hope someone can give me a hint, a thread on the forum or some searching
aid:-)
--
Bjørge
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php