2
テーブルとそのデータを動的に出力したい。私はデータソースとテーブル名を持っています。ColdFusionを使用して列名を持たないMySQLを動的に出力
<cftable>
を使用してみましたが、動的な列名が付いています。
これは基本的に私がやりたいことです。明らかに機能しませんが、ここでは説明のためです。
<cfset datasource = "test">
<cfset tablename = "mytable">
<!--- first get the columns from the table --->
<cfquery name="getcolumns" datasource="#datasource#">
SELECT COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = '#mytable#';
</cfquery>
<!--- Now select all from the table --->
<cfquery name="selectall" datasource="#datasource#">
SELECT *
FROM #mytable#
</cfquery>
<!--- Output all rows from the table --->
<cftable query="selectall">
<cfoutput query="getcolumns">
<cfcol text="#COLUMN_NAME#" header="#COLUMN_NAME#">
</cfoutput>
</cftable>
この質問は次のようになりますhttps://stackoverflow.com/questions/22601325/looping-columns-in-coldfusion-along-with-values-in-correct-order –