Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

coldfusion list & each function

Status
Not open for further replies.

LAdProg2005

Programmer
Feb 20, 2006
56
US
Hello,

I am fairly new to coldfusion...I am converting scripts from php to coldfusion.

two of the functions in php (list() & each ())
I cannot find in coldfusion...Not exact but similar functions...

I will appreciate any pointers in this regards...basically what i am trying to do is

i have structure populated from the results of query and to i need to loop through it accodingly

i.e. info->structure from three queries: info[txt][loc][year][day]['test1']=totalNum;
info[txt][loc][year][day]['test2']=totalNum;
info[txt][loc][year][day]['test3']=totalNum
when i dump this structure in coldfusion:
result:
cmp1->il->2009->03->test1(1)test2(1)test3(1)
tx->2009->03->test1(2)test2(2)test3(2)
ny->2009->02->test1(1)test2(1)test3(1)
&
cmp2->il->2009->03->test1(1)test2(1)test3(1)
tx->2009->03->test1(1)test2(1)test3(1)
ny->2009->03->test1(1)test2(1)test3(1)

---following is what i need to do but i am having hard time to write it in coldfusion----
while (list ($txt, $vtxt) = each ($info)){
while (list ($loc, $vloc) = each ($info[$loc])) {
do something
}
}

Thanks,
p
 
i have structure populated from the results of query

Though it does not answer your question, I would ask is it really necessary to convert the query to a structure? In many cases that just adds unnecessary complexity. If you are just displaying the results, you might be able to produce the same results using a "grouped" <cfoutput...>.

----------------------------------
 

Thanks for replying...

actually,
i was able to accomplish using

<cfloop list="#StructKeyList(info)#" index="txt">

<cfloop list="#StructKeyList(info[txt])#" index="loc">
do something
</cfloop>
</cfloop>

I didn't know how to accomplish..i think it would be ok to use cfoutput or qoq...but thinking of having to go through 5 iterations i thought there must be a better way or may be i am missing something there....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top