Link to home
Start Free TrialLog in
Avatar of James Rodgers
James RodgersFlag for Canada

asked on

joining form submission with query output

I have a form which submits raw data whic is to be compiled and commented on in the submission page, the compiled data is stored in a mutlidimentional array with the ket to a database item stored at [x][1]
the array is sorted in descending orderby the total [x][5] sample;
B-1-1-3-5
A-2-1-1-4
C-1-2-1-4
D-1-1-1-3
E-1-1-1-3
F-1-1-1-3
G-1-1-1-3
H-1-1-1-3
I-1-1-1-3
J-1-1-1-3

how can i loop the array and retreive the corresponding database reference without having to query the databse at each iteration of the loop?
B-1-1-3-5
^ key to database item
B field1 field2
databse table
Avatar of hart
hart
Flag of India image

http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/arrayStruct4.htm

check this link out for looping on multidimensional arrays.

Regards
Hart
Avatar of Mause
Mause

I'm not sure what you exactly want but the link from Hart will explane you how to loop over a 2d array.

it will be something like this I gues:

<cfloop index="loopy" from="1" to="#ArrayLen(myarray)#">
   #loopY#
  <cfloop index="loopx" from="1" to="#ArrayLen(myarray[loopy])#">
        -#loopx#
  </cfloop>
   <br>
</cfloop>

The output of this loop will be
B-1-1-3-5
A-2-1-1-4
C-1-........

Mause
Avatar of James Rodgers

ASKER

I probably wasn't clear enough in the description
i have an array which i have populated with form submission details and sorted according to a specific value

i want to use the array and the results of a query to output combined details where the item data in array[x][1]=the key field value form the array - without having to requery on each iteration so rather than

<cfloop from="1" to="#arrayLen(myArray)#" index="idx">
   <cfquery name="getElements">
      SELECT QID, QTEXT, SKILLREF
      FROM ELEMENTS
      WHERE QID=#myArray[idx][1]#
   </cfquery>
   <cfloop query="getElements>
      //output details here
   </cfloop>
</cfloop>

i was looking for a method to accomplish the same results without needing to have a query within the loop

more like

<cfloop from="1" to="#arrayLen(myArray)#" index="idx">
   //find the row from query getElements where row[1]=#myArray[idx][1]#
   // outoput the details
</cfloop>
ASKER CERTIFIED SOLUTION
Avatar of hart
hart
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
perfect!!

thanks hart,

the find and list functions are two things i don't use enough to get a good understanding of thei capabilities

increased the points
Thats it hart!

But you only need one valuelist you can get the others by using this:
QTEXT : #getElements.QTEXT[nFind]#
SKILLREF : #getElements.SKILLREF[nFind]#



Mause
thanks man :-)

And Yeah Good One Mause !

Regards
Hart
Mause

I incorparated your code into the routine, please go here https://www.experts-exchange.com/questions/20808116/Points-for-Mause.html to get your points