Hello I'm new to ColdFusion, for my work I've been asked to learn it..

I'm coming from an extensive PHP background. For the life of me I cannot figure out how to simply take a query from SQL and load it into an array and then display it. I though this would be a very simple task which has become a headache.

Anyhow come code:

<!--- Show user details --->
<cfquery name="at" datasource="sql">
SELECT * FROM tbladmins

<cfset FieldIArray = ListToArray(at)>


The error lies in the cfset field, I don't understand how I can extract data from the query?

Can someone help thanks..

6 Years
Discussion Span
Last Post by cfwebdeveloper

cfquery returns information as a structure so if you want to exact data you can use queryname.columnname so in this case for example #at.username# would return whatever the first row of the query is.

You can use cfdump to view what the query is returning by doing cfdump(#at#).

Line 6 errors because cfquery does not return a list, it is a structure.

If you want to loop the query:

<cfloop query="at">
   <cfoutput>#at.lastName#, #at.firstName# <br /></cfoutput>


<cfoutput query="at">
   #at.lastName#, #at.firstName#

lastName and firstName would be my guess of column names since you used *

Let me know if this helps, you really dont need to convert this to an array unless there is more behind the question.

Edited by cfwebdeveloper: n/a


I'll get back to you on Sunday night (at a lan event). Thanks for the help!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.