dyg*_*gta 0 sql arrays coldfusion
好.所以我有这张桌子:
|项目| 数量| 价格|
|苹果| 2 | 2.00 |
|橙色| 3 | 1.50 |
|葡萄| 5 | 2.50 |
我想显示客户必须支付的总计.怎么做?enter code here
我真的不知道如何使用数组.任何人都可以告诉我如何?
我的代码(有点)
使用此查询在每行中显示价格:
<cfquery name="getPrice" datasource="fruits">
select *
from fruits
</cfquery>
<cfloop query="getPrice">
#quantity# | #price# | #totalPrice#
</cfloop><br>
Run Code Online (Sandbox Code Playgroud)
总计应显示在最后一行(总计= $ 21.00).
谢谢你的帮助.
<cfset grandTotal = 0 />
<cfloop query="getPrice">
#quantity# | #price# | #totalPrice#<br />
<cfset grandTotal = grandTotal + ( price * quantity ) />
</cfloop>
<br /><br />
<cfoutput>#grandTotal#</cfoutput>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3663 次 |
| 最近记录: |