I have a structure that's created based on field names in a database, like so..

<cfset electList=structnew()>
<cfset val=StructInsert(electList, "mayoralty", "Mayoralty")>
<cfset val=StructInsert(electList, "councillor_waikaka", "Councillor for Waikaka")>
<cfset val=StructInsert(electList, "src_gore", "Southland Regional Health Board - Gore")>
<cfset val=StructInsert(electList, "sdhb", "Southland District Health Board")>
<cfset val=StructInsert(electList, "gdhb", "Gore District Health Board")>
<cfset val=StructInsert(electList, "mlt_ward_2", "MLT Ward 2")>
<cfset val=StructInsert(electList, "mlt_ward_3", "MLT Ward 3")>
<cfset val=StructInsert(electList, "mlt_ward_4", "MLT Ward 4")>

I then loop over the structure and save each as a QoQ, like so..
<cfquery datasource="#request.dsn#" name="election_contested">
  SELECT
    contested_ID,mayoralty,councillor_waikaka,src_gore,
    sdhb,gdhb,mlt_ward_2,mlt_ward_3,mlt_ward_4
  FROM
    election_contested
</cfquery>

<cfloop collection=#electList# item="listItem">
  <cfquery dbtype="query" name="elect_#listItem#">
    SELECT   #listItem#
    FROM        election_contested
    WHERE   #listItem#
               <cfif CFVersion LT 6> <> '' <cfelse>IS NOT NULL</cfif>
  </cfquery>
</cfloop>

and on the output page I loop again, displaying them like so...

<cfloop collection=#electList# item="listItem">
  <h3><cfoutput>#electList[listItem]#</cfoutput></h3>
  <cfoutput query="elect_#listItem#">
#Evaluate(capFirstTitle(listItem))#<br />
  </cfoutput><br />
</cfloop>

This is all working -  BUT, the order they output in is neither alphabetical nor in the order I created my structure (which is how I want the output to look). I have no clue how the output order is being determined, nor  how to change it.  I've looked up StructKeySort but there's no reference to this in MX. Is there any way to change the output order to match the order of the structure?

TIA
Regards
MarkH
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to