Re: Sub Total in smarty
| From: | Mark Mitchenall | Date: | Thu, 04 Dec 2003 01:52:58 +0000 |
| Subject: | Re: Sub Total in smarty | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-10626@lists.php.net to get a copy of this message | ||
> {section name=i loop=$price}
> <hr>
> {$price[i].name} {$price[i].price}
> <hr>
> {/section}
>
> I lope through names and prices of some hardware, and I want to display
> total cost of all components. I dont know how to do that :( any help is
> appreciated.
You can use {assign} for this I think... e.g.
{assign var="total" value="0"}
{section name=i loop=$price}
<hr>
{assign var="total" value="
$total+$price[i].price"}
{$price[i].name} {$price[i].price}
<hr>
{/section}
Total: {$total}
HTH,
Mark
--
Mark Mitchenall
StandingWave Ltd
http://www.standingwave.co.uk/