Contents

cfelse

Description

Is the last case in a CFIF block to handle all other conditions that were not processed by any of the CFIF or CFELSEIF tags.

Category

Other

Implemented

Usage Syntax

<cfelse /> 

[] = Optional attribute

Attributes

No Attributes

Example Usage

Example:

In this example we will show how to vary the display results of a database query, which can be manipulated by using a very simple comparison expression in the CFIF tag.

	<---  Fetch the list of countries --->
	<cfquery name="getCountries" dbsource="regionalData">
		SELECT country_ID, country_Name, country_Capital
		FROM countries
		ORDER BY country_Name
	</cfquery>
	<---  Display our results using different conditions --->
	<p>Using the CFELSE tag we can list all the countries and empathize the ones which start with A or Z and strongly emphasize the countries that start with U.</p>
	<ul id="listedCountries">
	<cfquery query="getCountries">
		<cfif Left(getCountries.country_Name, 1) IS 'A' OR Left(getCountries.country_Name, 1) IS 'Z'>
			<li><em>#getCountries.country_Name#</em></li>
		<cfelseif Left(getCountries.country_Name, 1) IS 'U'>
			<li><strong>#getCountries.country_Name#</strong></li>
		<cfelse>
			<li>#getCountries.country_Name#</li>
		</cfif>
	</cfquery>
	</ul>