Home > Backend Development > PHP Tutorial > 关于Smarty的有关问题!

关于Smarty的有关问题!

WBOY
Release: 2016-06-13 10:15:23
Original
814 people have browsed it

请教高手 关于Smarty的问题!!!
如下购物车数组
$carts=array(
1=>array(name=>“Nokia 5510” , price=>800, qty=>2 ),
3=>array(name=>“Nokia 6610” , price=>1800, qty=>1 ),
4=>array(name=>“Nokia 7710” , price=>2800, qty=>1 ),
7=>array(name=>“Nokia 8810” , price=>2500, qty=>5 ),
}
用smarty循环,以表格形式显示购物车,表格行背景色有轮换效果,表格下有总额统计


------解决方案--------------------
在php页面里做好加法,传入smarty模板里就是了。smarty好像不管运算的。

循环加出
$sum
$smarty->assign("sum",$sum);

总金额:{$sum}
------解决方案--------------------
我查了一下手册,可以计算

在Math [数学运算] {assign var="foo" value="`$foo+$bar`"}

你的模板可以写成这样
HTML code
            <meta http-equiv="Content-Type" content="text/html; charset=gb2312">        <title></title>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template