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

  1. <!--- This example shows ArrayPrepend --->
  2. <HTML>
  3. <HEAD>
  4. <TITLE>ArrayPrepend Example</TITLE>
  5. </HEAD>
  6.  
  7. <BODY>
  8. <H3>ArrayPrepend Example</H3>
  9.  
  10. <CFQUERY NAME="GetEmployeeNames" DATASOURCE="cfsnippets">
  11. SELECT FirstName, LastName FROM Employees
  12. </CFQUERY>
  13. <!--- create an array --->
  14. <CFSET myArray = ArrayNew(1)>
  15. <!--- set element one to show where we are --->
  16. <CFSET myArray[1] = "Test Value">
  17. <!--- loop through the query and append these names
  18. successively before the last element (this list will
  19. reverse itself from the standard queried output, as
  20. it keeps prepending the array entry) --->
  21. <CFLOOP query="GetEmployeeNames">
  22.     <CFOUTPUT>#ArrayPrepend(myArray, "#FirstName# #LastName#")#</CFOUTPUT>, Array was prepended<BR>
  23. </CFLOOP>
  24. <!--- show the resulting array as a list --->
  25. <CFSET myList=ArrayToList(myArray, ",")>
  26. <!--- output the array as a list --->
  27. <CFOUTPUT>
  28.     <P>The contents of the array are as follows:
  29.     <P>#myList#
  30. </CFOUTPUT>
  31.  
  32. </BODY>
  33. </HTML>       
  34.