cfloop

CFLoop Error For Missing Entries

我怕爱的太早我们不能终老 提交于 2019-12-02 07:29:24
please disregard this post. I have made a clearer example of my problem here: Error with CFLoop When Entries Are Missing I am running the CFLoop code below. <cfset data = queryNew("sid,firstname,lastname,age","integer,varchar,varchar,integer")> <cfloop index="x" from="1" to="50"> <cfset queryAddRow(data)> <cfset querySetCell(data,"sid",x)> <cfset querySetCell(data,"firstname","#first[x]#")> <cfset querySetCell(data,"lastname","#last[x]#")> <cfset querySetCell(data,"age","#studentage[x]#")> </cfloop> <cfoutput query="data"> #sid# - #firstnamet# #lastname# - #age#<br /> </cfoutput> The variables

How to get a dynamic attribute name in cfloop over query in ColdFusion

十年热恋 提交于 2019-12-01 17:19:55
I'm inside a cfloop over a query. I want to get an attribute, but I won't know what that attribute will be until runtime. Using #qryResult[MyAttr]# fails with the error "Complex object types cannot be converted to simple values." What is the syntax for doing this? Here is a simplified example: <cfquery datasource="TestSource" name="qryResult"> SELECT * FROM MyTable </cfquery> <cfloop query="qryResult"> <cfset MyAttr="autoid" /> <cfoutput> Test 1: #qryResult.autoid# <br/> <!--- succeeds ---> Test 2: #qryResult[MyAttr]# <br/> <!--- fails ---> </cfoutput> </cfloop> <cfloop query="qryResult">

How to get a dynamic attribute name in cfloop over query in ColdFusion

十年热恋 提交于 2019-12-01 16:19:07
问题 I'm inside a cfloop over a query. I want to get an attribute, but I won't know what that attribute will be until runtime. Using #qryResult[MyAttr]# fails with the error "Complex object types cannot be converted to simple values." What is the syntax for doing this? Here is a simplified example: <cfquery datasource="TestSource" name="qryResult"> SELECT * FROM MyTable </cfquery> <cfloop query="qryResult"> <cfset MyAttr="autoid" /> <cfoutput> Test 1: #qryResult.autoid# <br/> <!--- succeeds --->