home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / querynew.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.1 KB  |  43 lines

  1. <!--- This example shows the use of QueryNew --->
  2.  
  3. <HTML>
  4.  
  5. <HEAD>
  6. <TITLE>
  7. QueryNew Example
  8. </TITLE>
  9. </HEAD>
  10.  
  11. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  12. <BODY  bgcolor="#FFFFD5">
  13.  
  14. <H3>QueryNew Example</H3>
  15.  
  16. <P>We will construct a new query with two rows:
  17. <!--- make a new query --->
  18. <CFSET myQuery = QueryNew("name, address, phone")>
  19. <!--- make some rows in the query --->
  20. <CFSET newRow  = QueryAddRow(MyQuery, 2)>
  21.  
  22. <!--- set the cells in the query --->
  23. <CFSET temp = QuerySetCell(myQuery, "name", "Fred", 1)>
  24. <CFSET temp = QuerySetCell(myQuery, "address", "9 Any Lane", 1)>
  25. <CFSET temp = QuerySetCell(myQuery, "phone", "555-1212", 1)>
  26.  
  27. <CFSET temp = QuerySetCell(myQuery, "name", "Jane", 2)>
  28. <CFSET temp = QuerySetCell(myQuery, "address", "14 My Street", 2)>
  29. <CFSET temp = QuerySetCell(myQuery, "phone", "588-1444", 2)>
  30.  
  31.  
  32. <!--- output the query --->
  33. <CFOUTPUT query="myQuery">
  34. <PRE>#name#    #address#    #phone#</PRE>
  35. </CFOUTPUT>    
  36. To get any item in the query, we can output it individually
  37. <CFOUTPUT>
  38. <P>Jane's phone number: #MyQuery.phone[2]#
  39. </CFOUTPUT>
  40. </BODY>
  41.  
  42. </HTML>       
  43.