Solved

Database stuff

Posted on 2001-06-06
3
130 Views
Last Modified: 2013-12-24
Anyone have any idea how to add the values that are retrieved form a database table as the come out....i.e

<cfquery...
Select....

<cfoutput>...


#price# + #nextprice#...etc

...

basically adding up the amount in a shopping basket as they are read out.

Thanks.
P
0
Comment
Question by:Peridot
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
CF_Spike earned 100 total points
ID: 6159527
You can do it something like this. The code below will output the price for each item in the cart and show the total price in a row at the bottom.


<!--- this table is just here for formatting purposes you don't need it --->
<TABLE BORDER="1">
<TR>
<TH>
Prices
</TH>
</TR>

<!--- Create a variable to hold the total price so far --->
<CFSET TotalPrice = 0>

<!--- output the query --->
<CFOUTPUT Query="myQuery">
<!--- increment the total price --->
<CFSET TotalPrice = TotalPrice + myQuery.price>

<!--- Again these table rows and cells are just for display purposes you can display the prices any way you like --->
<TR>
<TD>
#myQuery.price#
</TD>
</TR>

<!--- end looping of the query --->
</CFLOOP>

<!--- output the total price --->
<TR>
<TD>
#TotalPricef#
</TD>
</TR>
<!--- close the table --->

</TABLE>

Hope that helps

Spike
0
 
LVL 4

Expert Comment

by:CF_Spike
ID: 6159528
You can do it something like this. The code below will output the price for each item in the cart and show the total price in a row at the bottom.


<!--- this table is just here for formatting purposes you don't need it --->
<TABLE BORDER="1">
<TR>
<TH>
Prices
</TH>
</TR>

<!--- Create a variable to hold the total price so far --->
<CFSET TotalPrice = 0>

<!--- output the query --->
<CFOUTPUT Query="myQuery">
<!--- increment the total price --->
<CFSET TotalPrice = TotalPrice + myQuery.price>

<!--- Again these table rows and cells are just for display purposes you can display the prices any way you like --->
<TR>
<TD>
#myQuery.price#
</TD>
</TR>

<!--- end looping of the query --->
</CFLOOP>

<!--- output the total price --->
<TR>
<TD>
#TotalPrice#
</TD>
</TR>
<!--- close the table --->

</TABLE>

Hope that helps

Spike
0
 

Author Comment

by:Peridot
ID: 6159899
Thanks Spike.
0

Featured Post

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now