Adobe Dreamweaver Forums



Last 10 THreads :         flash download on Vista (Last Post : preppy789 - Replies : 0 - Views : 1 )           »          spry menubars not lining up in IE (Last Post : orierstiZ - Replies : 149 - Views : 543 )           »          Writing mxml transition in as3 (Last Post : SiHoop - Replies : 0 - Views : 1 )           »          Is There An Extension that Renames Layers Based on MovieClip Names of Files (Last Post : fcastro75 - Replies : 4 - Views : 5 )           »          file directory. (Last Post : Alan - Replies : 10 - Views : 11 )           »          Lining up flash video in different browsers... (Last Post : Jasper Thayer - Replies : 1 - Views : 2 )           »          Uploading Streaming Video (Last Post : K.A.M. - Replies : 2 - Views : 6 )           »          How do I Set Text of Container? (Last Post : lazybones99 - Replies : 2 - Views : 3 )           »          Locking resize handles in browser. (Last Post : emilio_tha_don - Replies : 10 - Views : 11 )           »          gesture driven scrolling list (Last Post : cntpmaxn - Replies : 64 - Views : 953 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Cold Fusion
 
Tags:

Reply
  #1 (permalink)  
Old 07-24-2008, 12:55 PM
chrispilie
 
Posts: n/a
Diggs:
Default math

I am trying to do some simple math equations with data from a query. This is
what it may look like.

#queryname.VariableA*#(#queryname.VariableB#/#quer yname.VariableC#) Is there
any ideas?

I can get these to work when setting them within a query of query but when I
loop the variables they populate every value with its associated column. Here
is the example:

<CFQUERY NAME="GetEarned" DBTYPE="query">
SELECT
TaskDesc.QTYComplete AS QTYComplete,
TaskDesc.Manhours AS Manhours,
(TaskDesc.Manhours *(TaskDesc.QTYComplete / TaskDesc.QTY)) AS Earned,
(TaskDesc.QTYComplete / TaskDesc.QTY) AS PercentComplete
FROM TaskDesc
</CFQUERY>


------------------------------------------
<!--- Add JSA Task --->
</TR><br>
<CFLOOP QUERY="TaskDesc" startrow="#URL.StartRow#"
endrow="#EndRow#"><cfoutput>
<TR>
<!--- Cust name --->
<TD><table width="550" border="1" bordercolor="FFFFFF"
cellspacing="0" cellpadding="0">
<tr>
<td width="100" align="center"><font size="-1">#ActivityID#</font></td>
<td width="200" align="center"bgcolor="FFFFFF"><font
size="-2">#ActivityDescription#</font></td>
<td width="50" align="center"><font size="-2">

<cfif GetEarned.QTYComplete IS "0">0
<cfelse>#GetEarned.Earned#</cfif>

</font></td>
<td width="50" align="center"><font size="-2">#Manhours#</font></td>
<td width="50" align="center"bgcolor="FFFFFF"><font size="-1"
color="006633">

<cfif GetEarned.QTYComplete IS "0">0
<cfelse>#GetEarned.PercentComplete#</cfif>

</cfoutput></cfloop>

I did get rid of some html code to clean it up a bit.

Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2008, 12:55 PM
Dan Bracuk
 
Posts: n/a
Diggs:
Default Re: math

It would be simpler to add the math to the original query. Your q of q shows that you know how to do this.
Reply With Quote
  #3 (permalink)  
Old 07-24-2008, 12:55 PM
GArlington
 
Posts: n/a
Diggs:
Default Re: math

On Jul 24, 12:35 pm, "chrispilie" <webforumsu...@macromedia.com>
wrote:
> I am trying to do some simple math equations with data from a query. This is
> what it may look like.
>
> #queryname.VariableA*#(#queryname.VariableB#/#quer yname.VariableC#) Is there
> any ideas?

<cfset res = queryname.VariableA*(queryname.VariableB/
queryname.VariableC) />
will work as well as your equation if you move * (multiplication)
outside the # [I suspect that this is just a typo in this post]
For your future posts DO NOT re-type your code - COPY and PASTE
exactly what you have...
>
> I can get these to work when setting them within a query of query but when I
> loop the variables they populate every value with its associated column...

Did you mean column name in ##?
Then you forgot to put <cfoutput ...>...</cfoutput> around your
equation...
<snap>
Reply With Quote
  #4 (permalink)  
Old 07-24-2008, 12:55 PM
GArlington
 
Posts: n/a
Diggs:
Default Re: math

On Jul 24, 12:35 pm, "chrispilie" <webforumsu...@macromedia.com>
wrote:
> I am trying to do some simple math equations with data from a query. This is
> what it may look like.
>
> #queryname.VariableA*#(#queryname.VariableB#/#quer yname.VariableC#) Is there
> any ideas?
>
> I can get these to work when setting them within a query of query but when I
> loop the variables they populate every value with its associated column. Here
> is the example:
>
> <CFQUERY NAME="GetEarned" DBTYPE="query">
> SELECT
> TaskDesc.QTYComplete AS QTYComplete,
> TaskDesc.Manhours AS Manhours,
> (TaskDesc.Manhours *(TaskDesc.QTYComplete / TaskDesc.QTY)) AS Earned,
> (TaskDesc.QTYComplete / TaskDesc.QTY) AS PercentComplete
> FROM TaskDesc
> </CFQUERY>
>
> ------------------------------------------
> <!--- Add JSA Task --->
> </TR><br>
> <CFLOOP QUERY="TaskDesc" startrow="#URL.StartRow#"
> endrow="#EndRow#"><cfoutput>
> <TR>
> <!--- Cust name --->
> <TD><table width="550" border="1" bordercolor="FFFFFF"
> cellspacing="0" cellpadding="0">
> <tr>
> <td width="100" align="center"><font size="-1">#ActivityID#</font></td>
> <td width="200" align="center"bgcolor="FFFFFF"><font
> size="-2">#ActivityDescription#</font></td>
> <td width="50" align="center"><font size="-2">
>
> <cfif GetEarned.QTYComplete IS "0">0
> <cfelse>#GetEarned.Earned#</cfif>
>
> </font></td>
> <td width="50" align="center"><font size="-2">#Manhours#</font></td>
> <td width="50" align="center"bgcolor="FFFFFF"><font size="-1"
> color="006633">
>
> <cfif GetEarned.QTYComplete IS "0">0
> <cfelse>#GetEarned.PercentComplete#</cfif>
>
> </cfoutput></cfloop>
>
> I did get rid of some html code to clean it up a bit.


BTW:
<cfloop query="queryName" ...>
<cfoutput>
....
</cfoutput>
</cfloop>
can be replaced with shorter
<cfoutput query="queryName" ...>
....
</cfoutput>
Reply With Quote
  #5 (permalink)  
Old 07-24-2008, 02:29 PM
chrispilie
 
Posts: n/a
Diggs:
Default Re: math

Sometimes I can't see the forest through the trees! My loop was looping the main query no the query of the main. Thanks for the help
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 02:17 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk