Tay*_*PLM 4 coldfusion conditional
好吧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>
Run Code Online (Sandbox Code Playgroud)
当RecordCount返回大于0的数字时,else情况正确显示.当RecordCount返回0时,不显示任何内容,并且表单沿其路径继续.我变得非常沮丧,因为这应该很简单......
小智 12
如果查询集为空,则输出不会返回任何结果.尝试:
<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>
Run Code Online (Sandbox Code Playgroud)
我假设您要返回一些记录...如果您只是返回一个,query="checkForAd"则没有必要.您可以简单地引用一个查询和变量<cfoutput></cfoutput>.
编辑
这是访问查询变量的一种方法: QueryName["ColumnName"][RowNum]
(当你想扩展你的编码时,你可以用查询变量做很多事情.在ColdFusion和从MySQL获取数据的不同方法有很好的概述)
| 归档时间: |
|
| 查看次数: |
19180 次 |
| 最近记录: |