title: Nested Loops Multiple Entries
body: <p>I ran into another problem. I'm trying to figure out how to only have 1 record set of the <code>newResult</code> variable instead of it displaying many times?</p>
  
  <p>qrykeylist is from the database.
  and newArray is not from database but constructed from the array.</p>
  
  <p>I needed to loop over both in order to get all the results. I managed to get them how I wanted but I cannot figure out how to make it only show 1 record result set from both of the looped over results from both the query and array.</p>
  
  <p>I googled around and some have told me when having nested loops put both into an array of structures but how can I do that if both of these needs to be looped over? In addition, I cannot write this outside of inner loop because I need to use BOTH variables to output the results.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;cfoutput&gt;
      &lt;cfloop index="i" from="1" to="#ArrayLen(newArray)#"&gt;
          &lt;cfloop query="qrykeylist"&gt;
              &lt;strong&gt;&lt;br&gt;#ITEM[i]#&lt;/strong&gt;
              &lt;cfset newResult = SHOULDBE - newArray[i]&gt;
                  &lt;cfif newArray[i] GT SHOULDBE&gt;
                      &lt;br&gt;Missing Keys #newResult#
                      &lt;cfelseif newArray[i] LT SHOULDBE&gt;
                      &lt;br&gt;Extra Keys #newResult#
                      &lt;cfelseif newArray[i] EQ SHOULDBE&gt;
                      &lt;br&gt;No Missing Keys
                  &lt;/cfif&gt; 
                  &lt;cfbreak&gt;
          &lt;/cfloop&gt;
      &lt;/cfloop&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the results of the image the ones that arent in boxes are being duplicated most likely by the loop?</p>
  
  <p><a href="https://i.stack.imgur.com/INlHb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/INlHb.jpg" alt="enter image description here"></a></p>