Scott,
there are some variables that you should know about. First,
"queryname.recordcount" - it contains an int representing the number of rows
in your recordset. Ints can be evaluated as boolean in CF (any non-zero int
is "true") so you can do....
<cfif myQueryName.recordcount>
.....take action here.
</cfif>
As far as an array, the query is already an array of structures and CF
provides a number of ways to access the data. Cfoutput and Cfloop are the
most common. The syntax is:
<cfoutput query="myQueryName">
#column1# - #column2#
Or you might have logic here....
<cfif Firstname IS 'bill'>
Use color blue
<cfelse>
Use color Red.
</cfif>
</cfoutput>
CF output automaticlly loops through the recordset to the end. CF loop does
the same thing:
<cfloop query="myQueryName">
The difference here is that simply putting a variable in pound signs won't
automatically send it to
the output stream - so Cfloop is usally used for processing type code:
<cfif Groupname IS 'Admin'>
<cfset Permissions.access = 'Administrator'>
</cfif>
</cfloop>
You get the idea....
Please note that several tags in CF take the query attribute - notably
CFMail. Also, you may create a query object directly using the query
functions and some tags return a query object - or at least CAN return a
query object (CFPOP, CFFILE, CFHTTP).
Hope this helps.
-Mark
-----Original Message-----
From: Scott Wilhelm [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 13, 2003 2:56 PM
To: CF-Talk
Subject: Database Results
When I used to work with ASP, I would run my SQL statement, check to see
if the recordset is empty or not, if it wasn't, I'd roll it up into an
array, and the loop through the array.
I know how to do the SQL statement, and how to loop through it, but how
would I check to see if the result of the query contained results or
not, and how would I put the results in an array, and then how would I
loop through that array?
I'm sorry for asking so many questions...I'm in a new job which is also
a new developing environment...and I have very little time to learn all
this...
Any & all help is greatly appreciated, as I know everyone in here is
strapped for time as well.
Thanks,
Scott
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4