home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Documentation / snippets / listqualify.cfm < prev    next >
Encoding:
Text File  |  1999-04-12  |  1.9 KB  |  63 lines

  1. <!--- This example uses ListQualify to put quotes around each 
  2.       employees full name --->
  3. <HTML>
  4. <HEAD>
  5. <TITLE>ListQualify Example</TITLE>
  6. </HEAD>
  7.  
  8. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  9.  
  10. <BODY  bgcolor="#FFFFD5">
  11.  
  12. <CFQUERY Name="GetEmployeeNames" DATASOURCE="cfsnippets">
  13. SELECT     FirstName, LastName
  14. FROM     Employees
  15. </CFQUERY>
  16.  
  17. <H3>ListQualify Example</H3>
  18. <P>This example uses ListQualify to place the full names of the employees found
  19. in the query within quotation marks.</P>
  20.  
  21. <CFSET myArray = ArrayNew(1)>
  22.  
  23. <!--- loop through the query and append these names
  24.       successively to the last element --->
  25.       
  26. <CFLOOP query="GetEmployeeNames">
  27.     <CFSET temp= #ArrayAppend(myArray, "#FirstName# #LastName#")#>
  28. </CFLOOP>
  29.  
  30. <!--- sort that array descending alphabetically --->
  31. <CFSET myAlphaArray = ArraySort(myArray, "textnocase")>
  32.  
  33. <!--- show the resulting array as a list --->
  34. <CFSET myList=ArrayToList(myArray, ",")>
  35.  
  36. <CFOUTPUT>
  37.     <P>The contents of the unqualified list are as follows:    </P>
  38.     #myList#
  39. </CFOUTPUT>
  40.  
  41. <!--- show the resulting alphabetized array as a qualified 
  42.       list with single quotes around each full name.        --->
  43. <CFSET qualifiedList1=ListQualify(myList,"'",",","CHAR")>
  44.  
  45. <!--- output the array as a list --->
  46. <CFOUTPUT>
  47.     <P>The contents of the qualified list are as follows:    </P>
  48.     <P>#qualifiedList1#</P>
  49. </CFOUTPUT>
  50.  
  51. <!--- show the resulting alphabetized array as a qualified 
  52.       list with quotation marks around each full name. Note that 
  53.       we use " to denote quotation marks because the 
  54.       quotation mark character is a control character.         --->
  55. <CFSET qualifiedList2=ListQualify(myList,""",",","CHAR")>
  56.  
  57. <!--- output the array as a list --->
  58. <CFOUTPUT>
  59.     <P>The contents of the second qualified list are as follows:    </P>
  60.     <P>#qualifiedList2#</P>
  61. </CFOUTPUT>
  62. </BODY>
  63. </HTML>