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

  1. <!--- This example shows ArrayToList --->
  2.  
  3. <HTML>
  4. <HEAD>
  5. <TITLE>ArrayToList Example</TITLE>
  6. </HEAD>
  7.  
  8. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  9. <BODY  bgcolor="#FFFFD5">
  10.  
  11. <H3>ArrayToList Example</H3>
  12.  
  13. <CFQUERY NAME="GetEmployeeNames" DATASOURCE="cfsnippets">
  14. SELECT FirstName, LastName FROM Employees
  15. </CFQUERY>
  16. <!--- create an array --->
  17. <CFSET myArray = ArrayNew(1)>
  18. <!--- loop through the query and append these names
  19. successively to the last element --->
  20. <CFLOOP query="GetEmployeeNames">
  21.     <CFSET temp= #ArrayAppend(myArray, "#FirstName# #LastName#")#>
  22. </CFLOOP>
  23. <!--- show the resulting array as a list --->
  24. <CFSET myList=ArrayToList(myArray, ",")>
  25. <!--- sort that array descending alphabetically --->
  26. <CFSET myAlphaArray = ArraySort(myArray, "textnocase", "desc")>
  27. <!--- show the resulting alphabetized array as a list --->
  28. <CFSET myAlphaList=ArrayToList(myArray, ",")>
  29. <!--- output the array as a list --->
  30. <CFOUTPUT>
  31.     <P>The contents of the list are as follows:
  32.     <P>#myList#
  33.     <P>This list, alphabetized by first name (descending):
  34.     <P>#myAlphaList#
  35.     <P>This array has #ArrayLen(MyArray)# elements.
  36. </CFOUTPUT>
  37.  
  38. </BODY>
  39. </HTML>       
  40.