【发布时间】:2013-02-08 07:06:27
【问题描述】:
我正在尝试遍历包含我需要显示的列名的数组。用户可以定义自己的列,因此这将是一个动态列名列表
例如,列名可能是:
["style", "color", "size"]
这些是我需要从名为results 的查询中输出的列名。
我正在这样做:
<cfset variables.styleText = "">
<cfloop array="#DeserializeJSON(variables.raw.field_names)#" index="x">
<cfset variables.styleText = variables.styleText & "#results." & x &"# ">
</cfloop>
<cfoutout>variables.styleText</cfoutput>
但这给了我一个错误,因为我不能用 quot aka 结束变量名
Diagnose: A CFML variable name cannot end with a "." character.
The variable results. ends with a "." character.
You must supply an additional structure key or delete the "." character.
问题:
谁能给我一个提示,在这种情况下,我需要如何修改它以输出我的 results 查询中的值
#results.style# #results.color# #results.size#?
谢谢!
【问题讨论】:
标签: variables dynamic coldfusion output