Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ColdFusion: get amount of results from a query

Tags:

coldfusion

I have some ColdFusion output:

<cfoutput query="myList">#Email#</cfoutput>

If my list happens to have several results, this output loops and prints out all the emails. However, if there are no results, I would like to write a statement to output a message...

How does this work? It seems like #Email# is a variable, but it can also be an array...how do I count the number of results when using like this?

update: I have also tried using a stored procedure to do a COUNT, which gives me the amount...but I'm not sure how to use the results of the stored procedure in a coldfusion <cfif> statement...

like image 529
redconservatory Avatar asked Dec 17 '22 05:12

redconservatory


1 Answers

<cfif myList.RecordCount>
  <cfoutput query="myList">#Email#</cfoutput>
<cfelse>
  No results
</cfif>

is what you are looking for, and is the strategy most commonly employed by ColdFusion developers.

like image 194
Shawn Holmes Avatar answered Jan 06 '23 22:01

Shawn Holmes