0
        <form action="blog.Logboek" method="post" name="Update_what">
           <select size="1" name="Whats">
               <option>Select an item</option>
                <cfloop array="#VARIABLES.Whats#" item="What_name">
               <option VALUE="#What.id#">#item.What_name#</option>
                </cfloop>
           </select>
           <input type="submit" value="Update_what">
       </form>

我得到一个项目列表,其中包含选项标签之间的内容,而不是数据库中的项目。

我究竟做错了什么?

4

1 回答 1

1

如我所见,您的数组名为Whats. 您为什么要尝试从名为 的变量中获取值What?此外,您调用不当item.What_name

你应该像你一样循环Whats并使用index属性,例如。row.

<cfloop array="#VARIABLES.Whats#" index="row">
    <option VALUE="#row.id#">#row.<thing_you_want_to_display>#</option>
</cfloop>

如果这将在cfoutput标签中,这将起作用。

评论更新:

注释中所述,只有 Lucee 支持item带有数组循环的属性。对于 Adob​​e ColdFusion,请改用该index属性

于 2016-01-21T09:44:14.277 回答