Solved

Database stuff

Posted on 2001-06-06
3
132 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

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…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

778 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