Hey guys,
I'm trying to display my results from a CFQuery in a specific order. The order is to be maintained in the database so that it can be manipulated, and there are an unknown number of columns per table. The final row in the table is "ColumnOrder": each column has a number to specify it's sort order, 0 means "don't display". I'm trying to sort by looping say, "y" from 1 to maxCols:
0) do y = 1 to maxCols
1) in the sortColumn result set, use y to lookup the corresponding KEY
2) in the products result set, find the value from the corresponding KEY
3) insert said value into tempStruct[y]
4) loop.
I'm running into a wall trying to use structFindKey(). Here's my code:
<CFQUERY name="qParts" datasource="Pascal">
SELECT * FROM Turbos WHERE PartNumber LIKE <cfqueryparam cfsqltype="cf_sql_char" maxlength="30" value="%#mfr#%"> ORDER BY #sort# ASC
</CFQUERY>
<cfquery name="qPartsOrder" datasource="Pascal">
SELECT * FROM Turbos WHERE PartNumber = 'ColumnOrder'
</cfquery>
<cfset tempStruct=structnew()>
<cfloop index="columnOrder2" from="1" to="#ListLen(qPartsOrder.ColumnList, ',')#">
<cfdump var="#StructFindKey(qPartsOrder, columnOrder2)#">
<cfset tempStruct[columnOrder2] = StructFindKey(#qPartsOrder#, "#columnOrder2#")>
<cfset currentCol = "#ListGetAt(qParts.columnList, columnOrder2, ',')#">
<cfoutput>#qParts[currentCol][qParts.currentrow]# <br/></cfoutput>
</cfloop>
<cfdump var="#tempstruct#">
The line
<cfdump var="#StructFindKey(qPartsOrder, columnOrder2)#">
is throwing a BLANK!! error message, so I can't debug it and I'm stuck.
Any and all help would be appreciated (and YES I have to use SELECT *, this is a generic product display page for displaying ALL information in the database except a few which are denoted by a zero in the order column, remember?).