home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / arraytolist.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.1 KB  |  36 lines

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