ColdFusion RecordCount 作为多个条件
ColdFusion RecordCount as multiple conditional
我想 运行 一个查询 + 输出,如果没有记录存在 运行 第二个查询 + 输出,如果两个都没有记录然后重定向到
<test1.RecordCount eq 0>
但问题是我只能用一个<cfelse>
有什么想法吗?
一个查询的代码+输出和RecordCount
<cfif test1.RecordCount eq 0>
<!--- Display some message.--->
<cfelse>
<cfoutput query="test1">
<!--- Display some other message --->
</cfoutput>
</cfif>
如果我正确理解你的问题,你应该能够使用嵌套 <cfif ...>
条件。
类似于:
<cfif test1.RecordCount gt 0>
<cfoutput query="test1">
<!--- Display test1 query results --->
</cfoutput>
<cfelse>
<cfif test2.RecordCount gt 0>
<cfoutput query="test2">
<!--- Display test2 query results --->
</cfoutput>
<cfelse>
<!--- Display some message.--->
</cfif>
</cfif>
或者您可以这样使用 <cfelseif>
:
<cfif test1.RecordCount gt 0>
<cfoutput query="test1">
<!--- Display test1 query results --->
</cfoutput>
<cfelseif test2.RecordCount gt 0>
<cfoutput query="test2">
<!--- Display test2 query results --->
</cfoutput>
<cfelse>
<!--- Display some message.--->
</cfif>
我想 运行 一个查询 + 输出,如果没有记录存在 运行 第二个查询 + 输出,如果两个都没有记录然后重定向到
<test1.RecordCount eq 0>
但问题是我只能用一个<cfelse>
有什么想法吗?
一个查询的代码+输出和RecordCount
<cfif test1.RecordCount eq 0>
<!--- Display some message.--->
<cfelse>
<cfoutput query="test1">
<!--- Display some other message --->
</cfoutput>
</cfif>
如果我正确理解你的问题,你应该能够使用嵌套 <cfif ...>
条件。
类似于:
<cfif test1.RecordCount gt 0>
<cfoutput query="test1">
<!--- Display test1 query results --->
</cfoutput>
<cfelse>
<cfif test2.RecordCount gt 0>
<cfoutput query="test2">
<!--- Display test2 query results --->
</cfoutput>
<cfelse>
<!--- Display some message.--->
</cfif>
</cfif>
或者您可以这样使用 <cfelseif>
:
<cfif test1.RecordCount gt 0>
<cfoutput query="test1">
<!--- Display test1 query results --->
</cfoutput>
<cfelseif test2.RecordCount gt 0>
<cfoutput query="test2">
<!--- Display test2 query results --->
</cfoutput>
<cfelse>
<!--- Display some message.--->
</cfif>