我想运行一个查询+输出,如果没有记录,则运行第二个查询+输出,如果两个都没有记录,则重定向到
<test1.RecordCount eq 0>
但问题是我只能使用一个<cfelse>
有什么想法吗?
一个查询的代码+输出和RecordCount
<cfif test1.RecordCount eq 0>
<!--- Display some message.--->
<cfelse>
<cfoutput query="test1">
<!--- Display some other message --->
</cfoutput>
</cfif>
答案 0 :(得分:1)
如果我正确理解您的问题,您应该能够使用嵌套的<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>