-2
Я нахожу функцию для генерации столбцов HTML, и у меня возникают некоторые проблемы с синтаксисом, чтобы использовать имена столбцов переменных в запросе.Использование имен переменных столбцов в нотации объектов
<cffunction name="generateColumns" output=True>
<cfargument name="query">
<cfargument name="numberOfColumns">
<cfargument name="columnName">
<cfargument name="linkVariable">
<cfset html = ''>
<cfset itemsPerColumn = Ceiling(query.recordCount/3)>
<!--- Loop through each column --->
<cfloop from="1" to="#numberOfColumns#" index="outerIndex">
<cfset html = html & '<ul class="icf_nav-iblock">'>
<!--- Loop through the inner items --->
<cfloop from="1" to="#itemsPerColumn#" index="innerIndex">
<cfset totalIndex = ((outerIndex - 1) * itemsPerColumn) + innerIndex>
<cfset link = createRegressiveLink("#linkVariable#",query["#columnName#"][totalIndex])>
<cfset html = html & '<li data-id="' & query["#columnName#"][totalIndex] & '">'>
<cfset html = html & '<a href="' & link & '" class="icf_btn_small">'>
<cfset html = html & query["#columnName#"][totalIndex]>
<cfset html = html & '</a>'>
<cfset html = html & '</li>'>
</cfloop>
<cfset html = html & '</ul>'>
</cfloop>
<cfreturn html>
</cffunction>
Я получаю следующее сообщение об ошибке:
[Table (rows 10 columns VCHRMAKE): [VCHRMAKE: [email protected]] ] is not indexable by columnName
Я попытался
query["#columnName#"][totalIndex]
query["columnName"][totalIndex]
query[columnName][totalIndex]
, и я получаю ту же ошибку.