好吧,SO 用户...这是一个看似不可能出错的条件语句。这很简单,但是,我不明白为什么它不能按预期方式工作。
<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>
当 RecordCount 返回大于 0 的数字时,else 情况会正确显示。当 RecordCount 返回 0 时,不会显示任何内容,并且表单继续沿其路径移动。我变得非常沮丧,因为这应该很简单......
如果查询集为空,则输出不会返回任何结果。尝试:
<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>
我假设您希望返回多条记录...如果您只返回一条记录,则query="checkForAd"
没有必要。您可以简单地引用查询和变量<cfoutput></cfoutput>
.
Edit
这是访问查询变量的一种方法:QueryName["ColumnName"][RowNum]
(当您希望扩展您的编码时,您可以使用查询变量做很多事情。这里有关于不同方法的详细概述ColdFusion 并从 MySQL 获取数据 https://stackoverflow.com/questions/429219/coldfusion-and-getting-data-from-mysql)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)