Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Database stuff

Posted on 2001-06-06
3
Medium Priority
?
139 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
CF_Spike earned 300 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

670 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