CF is accessing the array QUESTION, which is undefined.

In your inner cfloop, try doing:

      <cfloop query="qGetTestResults">
          
<cfoutput>#qGetTestResults["question#i#"][gGetTestResults.currentRow]#</cfoutput><br
 />
      </cfloop>

This is possible because a query is just a structure, and the records 
are accessible via this format:

     queryname[columnName][rowNumber]

Also, CFOUTPUT has a query attribute, so you can change that inner 
cfloop to a cfoutput:

      <cfoutput query="qGetTestResults">
          #qGetTestResults["question#i#"][gGetTestResults.currentRow]#<br />
      </cfoutput>

Let me know if this worked for you.  Thanks!

- Rex

On 7/7/2011 11:32 AM, Gary Strommen wrote:
> I have a table with user answers from a test.  There are columns to hold the 
> answers with the column names of "question1", "question 2", "question3", .... 
> "question50".
>
> I want to loop through a query to show the answers.  Here is what I have:
>
> <!--- LOOP THROUGH THE NUMBER OF QUESTIONS (6 QUESTIONS) --->
> <cfloop from="1" to="#number_of_questions_in_test#" index="i">
>       <!--- THERE ARE THREE RECORDS, SHOW ALL THE RESULTS OF QUESTION1, THEN 
> QUESTION2, ... QUESTION6 --->
>       <cfloop query="qGetTestResults">
>           <cfoutput>#question[i]#</cfoutput><br />
>       </cfloop>
> </cfloop>
>
> The problem is, I keep getting an error "Variable QUESTION is undefined."  I 
> know this should be possible and it is probably a simple syntax error.
>
> Any suggestions?
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:5355
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to