Solved

Database stuff

Posted on 2001-06-06
3
129 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks Spike.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 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

9 Experts available now in Live!

Get 1:1 Help Now