Solved

How to compare two variables in different scope dynamically?

Posted on 2000-04-18
7
184 Views
Last Modified: 2013-12-24
I want to compare two query variables like this:

Query1 has a name fild with values a, b, c, d.
Query2 is a subset of Quer1. It also has a name fild with values a, or b, or c, or d, or any combination of them.

I tried the following code:

<CFLOOP NAME="Query1">
      <CFLOOP NAME="Query2">
           <CFIF Compare(Query1.name, Query1.name) is 0>
                <br>A match found!!!<br>                
           </CFIF>    
      </CFLOOP>
</CFLOOP>

My problem is that Query1.name in the comparation statement is still a, it never changed to b, c, d. I tried to use Evaluate function, but it helpless.

Could You help me?

Thanks.

Jun
0
Comment
Question by:liuj
  • 3
  • 3
7 Comments
 
LVL 2

Expert Comment

by:dlewis9
ID: 2728208
Try not using the query identifier in front of the variable..when you do, that only gives you the first record of the query..

<CFLOOP QUERY="Query1">
  <CFSET somevar = name>
      <CFLOOP QUERY="Query2">
           <CFIF Compare(somevar, name) is 0>
                <br>A match found!!!<br>                  
           </CFIF>      
      </CFLOOP>
</CFLOOP>

0
 

Author Comment

by:liuj
ID: 2728402
Thanks for your help.
I tried the similare way, and print out  somevar in outer loop and in inner loop, like this:

<CFLOOP QUERY="Query1">
        <CFSET somevar = name>
             <br>1. #somevar# <br>
        <CFLOOP QUERY="Query2">
            <br>2. #somevar# <br>
             <CFIF Compare(somevar, name) is 0>
                      <br>A match found!!!<br>                              </CFIF>      
         </CFLOOP>
 </CFLOOP>

1. is correct, but 2. remains the same.
0
 
LVL 2

Expert Comment

by:dlewis9
ID: 2728656
2 would remain the same inside that second loop..your code should print:

1.a
2.a
a match is found!
2.a
2.a
2.a
1.b
2.b
2.b
a match is found!
2.b
2.b

etc..what output are you trying to get?

i'll test it on a server when i get a chance..
0
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 

Author Comment

by:liuj
ID: 2728725
Thanks  lot!

I retest it and get the right answer. Last time I got a incorrect result may be because some thing wrong with my account. Each time I need to ftp my programm into there.

Thanks again.
0
 
LVL 5

Expert Comment

by:nathans
ID: 2728855
If it works GRADE him.... Give him a 'A'

Nathan Stanford
Mr. ColdFusion
www.nsnd.com
ColdFusion Tips Plus
0
 

Author Comment

by:liuj
ID: 2729160
HOw can I grade the answer? I want grade A, but how?
0
 
LVL 2

Accepted Solution

by:
dlewis9 earned 100 total points
ID: 2729231
There should be a button on the comment that says "Accept comment as answer" and then you grade it after that..

Glad it worked for ya..i hate it when a web server doesn't use the page I just uploaded...darn caching..
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

791 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