home *** CD-ROM | disk | FTP | other *** search
- <!--- This example illustrates the use of CFSWITCH and
- CFCASE to exercise a case statement in CFML. --->
-
- <!--- Query to get some information. --->
- <CFQUERY NAME="GetEmployees" DATASOURCE="cfsnippets">
- SELECT Emp_ID, FirstName, LastName, EMail,
- Phone, Department
- FROM Employees
- </CFQUERY>
-
- <HTML>
- <HEAD>
- <TITLE>CFSWITCH Example</TITLE>
- </HEAD>
-
- <BASEFONT FACE="Arial, Helvetica" SIZE=2>
- <BODY bgcolor="#FFFFD5">
-
- <H3>CFSWITCH Example</H3>
-
- <!--- By outputting the query and using CFSWITCH,
- we can classify the output without using a CFLOOP construct.
- --->
- <CFOUTPUT query="GetEmployees">
- <CFSWITCH EXPRESSION=#Trim(Department)#>
- <!--- Each time the case is fulfilled, the specific
- information is printed; if the case is not fulfilled,
- the default case is output --->
- <CFCASE VALUE="Sales">
- #FirstName# #LastName# is in <B>sales</B><BR><BR>
- </CFCASE>
- <CFCASE VALUE="Accounting">
- #FirstName# #LastName# is in <B>accounting</B><BR><BR>
- </CFCASE>
- <CFCASE VALUE="Administration">
- #FirstName# #LastName# is in <B>administration</B><BR><BR>
- </CFCASE>
- <CFDEFAULTCASE>#FirstName# #LastName# is not in Sales,
- Accounting, or Administration.<BR>
- </CFDEFAULTCASE>
- </CFSWITCH>
- </CFOUTPUT>
-
- </BODY>
- </HTML>
-