Alright SO users... Here's a seemingly impossible to go wrong conditional statement. It is very simple, however, I cannot figure out why it won't work the way it is expected to.
<cfoutput query="checkForAd">
<!--- also used the line <cfif RecordCount eq 0> --->
<cfif checkForAd.RecordCount eq 0>
<!--- Display some message. (Perhaps using a table, undecided) --->
<cfelse>
<!--- Display some other message. (Happens to be a table) --->
</cfif>
</cfoutput>
When the RecordCount returns a number greater than 0, the else case displays properly. When RecordCount returns 0, nothing is displayed and the form continues along its path. I've become very frustrated as this should be quite simple...
The output won't return any results if the query set is empty. Try:
<cfif checkForAd.RecordCount eq 0>
<!--- Display some message. (Perhaps using a table, undecided) --->
<cfelse>
<cfoutput query="checkForAd">
<!--- Display some other message. (Happens to be a table) --->
</cfoutput>
</cfif>
I assume that you're looking to return a number of records... if you were just returning one, the query="checkForAd"
isn't necessary. You can simply reference the query & variables in a <cfoutput></cfoutput>
.
Edit
Here's one way to access a query variable: QueryName["ColumnName"][RowNum]
(As you look to expand your coding, there's a lot you can do with query variables. There's a great rundown of the different approaches at ColdFusion and getting data from MySQL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With