SunQuest
           ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old August 3rd, 2004, 10:29 AM
Brutality Brutality is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 24 Brutality User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Using a predefined variable in query output

I have what I had initially thought was a relatively easy request, however it hasn't quite proved that way, at least not just yet. With any luck I'm missing something simple.

A working example is easiest to start with:

<cfoutput query="results">
<tr bgcolor="#IIf(CurrentRow Mod 2, DE('ffffff'), DE('cccccc'))#">
<td>#team_name#</td>
<td>#round1#</td>
<td>#total_score#</td>
</tr>
</cfoutput>

From a previous query (results) I want to output in a table the results for each of the columns listed above; team_name, round1, and total_score - but I dont want to have to hard code round1, since that will depend on the round number. This is already set as another variable (called round_number).

However, when I try the following:

<cfoutput query="results">
<tr bgcolor="#IIf(CurrentRow Mod 2, DE('ffffff'), DE('cccccc'))#">
<td>#team_name#</td>
<td>#round("#round_number#")#</td>
<td>#total_score#</td>
</tr>
</cfoutput>

it outputs 1 repeatedly (which is the current round_number) in the middle column. As I have outlined, this is not what I want. I want the value from the column round(#round_number#), which in this case is round1.

Does that make sense?
All help greatly appreciated.

adieu
Mark

Reply With Quote
  #2  
Old August 3rd, 2004, 02:47 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
So are you saying that you don't want to hard code "round1" because sometimes it might be "round2", "round7", etc?

If that's the case, you could do something like:

<cfset round_number = "round1" />
<cfoutput query="results">
<tr bgcolor="#IIf(CurrentRow Mod 2, DE('ffffff'), DE('cccccc'))#">
<td>#team_name#</td>
<td>#round( evaluate( 'round_number' ) )#</td>
<td>#total_score#</td>
</tr>
</cfoutput>

You could probably do this without using evaluate, and instead using the array-like syntax for referencing the query column, but I wanted to see if this is what you are trying to achieve before I make things more complex.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old August 3rd, 2004, 04:46 PM
Brutality Brutality is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 24 Brutality User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
<snip>
So are you saying that you don't want to hard code "round1" because sometimes it might be "round2", "round7", etc?
</snip>

Yes, that's exactly what would happen. However, when I try your example I run into the same trouble as previously outlined:

#round( evaluate( 'round_number' ) )# only outputs the number 1 repeatedly, as opposed to making the query and pulling data from the round1 column.

Help!

Reply With Quote
  #4  
Old August 3rd, 2004, 08:48 PM
Brutality Brutality is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 24 Brutality User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
*smacks forehead* Here is a working solution..

<cfoutput query="results">
<tr bgcolor="#IIf(CurrentRow Mod 2, DE('ffffff'), DE('cccccc'))#">
<td>#team_name#</td>
<td>#results["round_#round_number#"][currentRow]#</td>
<td>#total_score#</td>
</tr>
</cfoutput>

regards
Mark

Reply With Quote
  #5  
Old August 3rd, 2004, 11:04 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
LOL, that's exactly the solution I was talking about when I mentioned doing it with the query array syntax. You jumped right to it, very nice.

Also, I think I just forgot the pound signs...I think this would also work:

#round( evaluate( '#round_number#' ) )#

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Using a predefined variable in query output


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway