House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Array and query References

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Hi,
Richard White
12/13/07 09:09 P
>#queryname["columnName"][1]#
Richard White
12/13/07 09:19 P
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Richard White
12/13/2007 09:09 PM

Hi, i have a query in which i dont know what the column names will be. however i have an array that contains the names of the columns but i am having difficulties in working out how i can reference the columns with the array. for example: if i have an array that has 2 elements: and i want to have a loop that loops through the array and an inner loop that loops through the query outputting the query results (using the array names to reference the columns) here is an example that i know wont work but i hope will help explain what i am trying to do: <cfloop index="i" from="1" to="#arraylen(myArray)#">   <cfloop index="a" from="1" to="#queryName.recordcount#">       <cfoutput>#queryName.myArray[i][a]#</cfoutput>   </cfloop> </cfloop> the 'myArray[i]' part of the cfoutput is obviously how i am trying to reference the name of the column but of course the error would be element myArray[i] doesnt exist in queryName. is there a way i can do this to correctly reference the column name using the array elements? thanks very much for your help richard

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dawson, Michael
12/13/2007 09:13 PM

I can't test it right now, for accuracy, but this is what I recall... #queryname["columnName"][1]# or #queryname[columnVar][1]# Also, you can get the column names by using #queryname.columnList#. M!ke Hi, i have a query in which i dont know what the column names will be. however i have an array that contains the names of the columns but i am having difficulties in working out how i can reference the columns with the array. for example: if i have an array that has 2 elements: and i want to have a loop that loops through the array and an inner loop that loops through the query outputting the query results (using the array names to reference the columns) here is an example that i know wont work but i hope will help explain what i am trying to do: <cfloop index="i" from="1" to="#arraylen(myArray)#">   <cfloop index="a" from="1" to="#queryName.recordcount#">       <cfoutput>#queryName.myArray[i][a]#</cfoutput>   </cfloop> </cfloop> the 'myArray[i]' part of the cfoutput is obviously how i am trying to reference the name of the column but of course the error would be element myArray[i] doesnt exist in queryName. is there a way i can do this to correctly reference the column name using the array elements? thanks very much for your help richard

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Richard White
12/13/2007 09:19 PM

>#queryname["columnName"][1]# thanks Michael this works perfectly :)


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference