Solved

Database stuff

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

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

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

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…
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

624 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