A generic CFTable output for all my tables
I am trying to build a set of pages to maintain my MySQL tables. I do not want to have to create one set for each table, just one set
for all of them. This means that I can never hard code table names or column names.
Here is a standard CFTable example:
<cftable
query="qAuthors"
border="yes"
maxrows="8"
startrow="1"
colspacing="1"
colheaders="yes"
htmltable="yes"
headerlines="1"
>
<cfcol header="Author ID" align="left" text="#AuthorID#">
<cfcol header="First Name" align="left" text="#FirstName#">
<cfcol header="Last Name" align="left" text="#LastName#">
</cftable>
Now, the query "qAuthors" can be made generic by using a #URL.Table" parameter passed from an unordered list on
the previous page. Now I need to put the
<cfcol header="Author ID" align="left" text="#AuthorID#">
into a generic CFLoop type iteration. To do this I need to know how many columns there are in the
table supplied by #URL.Table# parameter. I know how to do this by running a query on
column_name from the information_schema.columns table.
What I now need is a way of getting my main query to supply the column name for each row to subsititute
in the "cfcol header" part of the above statement plus the "text=" part. The number of columns variable will
then control how many rows are displayed and show the headers as well.
Any ideas?
Many thanks
