How to print all the result without using Results.columnname in ColdFusion
for ex:-
I have <cfquery name="getProductId">
select productId
from product
</cfquery>
In Product Table i have 2 columns with product_name and Product_id.
How can I print them without using getProductId.product_name getProductId.Product_id
Thanks,
What are you trying to achieve? If you are looking for a way to computationally output query results based on a query whose column names you do not know, such as...
...then you can use the
queryName.ColumnList
variable, which returns a comma separated list of all column names. You could subsequently iterate over this list, and output as required.For example, to get a simple HTML table output:
Apologies if this isn't what you meant!
Can you please clarify what means "without using column name"?
Maybe you want to use the getProductId.ColumnList attribute?
Small example from my old code that converts query to the array (a bit stripped details and changed var names, but shows the idea):
EDIT: enhanced example to get rid of row variable, as correctly noticed in comments.
To expand on my comment to Chris's response, here's the simpler version with the missing thead/tbody tags added:
Query to HTML table? there's a tag for that!
<CFTable>
FTW!http://www.cfquickdocs.com/cf8/#cftable :)