home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / cfswitch.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.2 KB  |  46 lines

  1. <!--- This example illustrates the use of CFSWITCH and
  2. CFCASE to exercise a case statement in CFML. --->
  3.  
  4. <!--- Query to get some information. --->
  5. <CFQUERY NAME="GetEmployees" DATASOURCE="cfsnippets">
  6. SELECT      Emp_ID, FirstName, LastName, EMail,
  7.             Phone, Department
  8. FROM         Employees
  9. </CFQUERY>
  10.  
  11. <HTML>
  12. <HEAD>
  13. <TITLE>CFSWITCH Example</TITLE>
  14. </HEAD>
  15.  
  16. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  17. <BODY  bgcolor="#FFFFD5">
  18.  
  19. <H3>CFSWITCH Example</H3>
  20.  
  21. <!--- By outputting the query and using CFSWITCH,
  22. we can classify the output without using a CFLOOP construct.
  23.  --->
  24. <CFOUTPUT query="GetEmployees">
  25. <CFSWITCH EXPRESSION=#Trim(Department)#>
  26. <!--- Each time the case is fulfilled, the specific
  27. information is printed; if the case is not fulfilled,
  28. the default case is output --->
  29.     <CFCASE VALUE="Sales">
  30.     #FirstName# #LastName# is in <B>sales</B><BR><BR>
  31.     </CFCASE>
  32.     <CFCASE VALUE="Accounting">
  33.     #FirstName# #LastName# is in <B>accounting</B><BR><BR>
  34.     </CFCASE>
  35.     <CFCASE VALUE="Administration">
  36.     #FirstName# #LastName# is in <B>administration</B><BR><BR>
  37.     </CFCASE>
  38.     <CFDEFAULTCASE>#FirstName# #LastName# is not in Sales,
  39.     Accounting, or Administration.<BR>
  40.     </CFDEFAULTCASE>
  41. </CFSWITCH>    
  42. </CFOUTPUT>
  43.  
  44. </BODY>
  45. </HTML>       
  46.