|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Array and query References
Hi,Richard White 12/13/07 09:09 P I can't test it right now, for accuracy, but this is what I recall...Dawson, Michael 12/13/07 09:13 P >#queryname["columnName"][1]#Richard White 12/13/07 09:19 P 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 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 >#queryname["columnName"][1]# thanks Michael this works perfectly :)
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||