home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / cfswitch.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.2 KB  |  44 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. <BODY bgcolor=silver>
  17. <H3>CFSWITCH Example</H3>
  18.  
  19. <!--- By outputting the query and using CFSWITCH,
  20. we can classify the output without using a CFLOOP construct.
  21.  --->
  22. <CFOUTPUT query="GetEmployees">
  23. <CFSWITCH EXPRESSION=#Trim(Department)#>
  24. <!--- Each time the case is fulfilled, the specific
  25. information is printed; if the case is not fulfilled,
  26. the default case is output --->
  27.     <CFCASE VALUE="Sales">
  28.     #FirstName# #LastName# is in <B>sales</B><BR><BR>
  29.     </CFCASE>
  30.     <CFCASE VALUE="Accounting">
  31.     #FirstName# #LastName# is in <B>accounting</B><BR><BR>
  32.     </CFCASE>
  33.     <CFCASE VALUE="Administration">
  34.     #FirstName# #LastName# is in <B>administration</B><BR><BR>
  35.     </CFCASE>
  36.     <CFDEFAULTCASE>#FirstName# #LastName# is not in Sales,
  37.     Accounting, or Administration.<BR>
  38.     </CFDEFAULTCASE>
  39. </CFSWITCH>    
  40. </CFOUTPUT>
  41.  
  42. </BODY>
  43. </HTML>       
  44.