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

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

struct/array problem with empty cells

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Les Mizzell
06/23/2012 02:57 PM

Need a little assistance with a struct/array problem please! ----------------------------------------------------------------------------------- Data in question is coming from ONE row in the database. There are six "fpcomm" cells: fpcomm1,fpcomm2, ... and so on There are also six "fpord" cells: fpord1, fpord2, ... and so on So, I need to display the contents of the fpcomm cells, ordered by the integer in the fpord cells. My query is "getNEWS". The below works great, and sorts the results as I need. <cfset allNEWS = StructNew()> <cfloop from="1" to="6" index="i">     <cfset oneSTORY = StructNew()>     <cfset oneSTORY.cellID = "#i#">     <cfset oneSTORY.ord = "#getNEWS["fpord#i#"][1]#">     <cfset oneSTORY.cell = "#getNEWS["fpcomm#i#"][1]#">     <cfset allNEWS[oneSTORY.cell] = oneSTORY> </cfloop> <cfset sortedKeys = StructSort(allNEWS, "numeric", "asc", "ord")> Here's the problem, maybe fpcomm5 and fpcomm6 are EMPTY (or NULL) on a particular day. REGARDLESS, I still need all six positions in "sortedKeys" returned. Let's say for the moment that fpcomm5 and fpcomm6 cells are empty. If I do a dump of "sortedKeys", I'll get: array 1   Item One 2   Item Two 3   Something Else 4   Even Something Else 5   [empty string] It INCLUDES the first emtpy row (fpcomm5), but NOT fpcomm6, which looks exactly like fpcomm5 in the database. If fpcomm4, 5, and 6 are empty, it will include fpcomm4, but not 5 and 6. Weird - it only include the FIRST empty element.... I need the array to always include all six elements. [empty string] is exactly what I need - but I need ALL of them. Suggestions?

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
lesmizz
06/23/2012 04:52 PM

>Weird - it only include the FIRST empty element.... Actually, if there are duplicate values for any of the "fpcomm" cells, it will only display the FIRST one. So, if fpcomm1 and fpcomm2 contains "Bob has News", it's only going to include fpcomm1 in the array.


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

Search cf-talk

June 19, 2013

<<   <   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             

Designer, Developer and mobile workflow conference