home *** CD-ROM | disk | FTP | other *** search
- <!--- This example shows the use of QueryNew --->
-
- <HTML>
-
- <HEAD>
- <TITLE>
- QueryAddColumn Example
- </TITLE>
- </HEAD>
-
- <BASEFONT FACE="Arial, Helvetica" SIZE=2>
-
- <BODY bgcolor="#FFFFD5">
-
- <BASEFONT FACE="Arial, Helvetica" SIZE=2>
- <BODY bgcolor="#FFFFD5">
-
- <H3>QueryAddColumn Example</H3>
-
- <P>This example adds three columns to a query object and then populates
- the columns with the contents of three arrays.</P>
-
- <P>After populating the query, the example shows, in tabular format, the
- contents of the columns.</P>
-
- <!--- make a new query --->
- <CFSET Employees = QueryNew("")>
-
- <!--- create an array --->
- <CFSET EmpNamesArray = ArrayNew(1)>
- <CFSET EmpNamesArray[1] = "Jane Smith">
- <CFSET EmpNamesArray[2] = "Bertrand Russell">
- <CFSET EmpNamesArray[3] = "Bronco Horvath">
- <CFSET EmpNamesArray[4] = "Angelica Huston">
-
- <!--- add a column to the query --->
- <CFSET nColumnNumber = QueryAddColumn(Employees, "Name", EmpNamesArray)>
-
- <!--- create a second array --->
- <CFSET PhoneNoArray = ArrayNew(1)>
- <CFSET PhoneNoArray[1] = "617-222-2323">
- <CFSET PhoneNoArray[2] = "781-347-4545">
- <CFSET PhoneNoArray[3] = "781-348-5565">
-
- <!--- add a second column to the query --->
- <CFSET nColumnNumber2 = QueryAddColumn(Employees, "PhoneNo", PhoneNoArray)>
-
- <!--- create a third array --->
- <CFSET LocationArray = ArrayNew(1)>
- <CFSET LocationArray[1] = "Santa Barbara">
- <CFSET LocationArray[2] = "Boston">
- <CFSET LocationArray[3] = "Boston">
- <CFSET LocationArray[4] = "Boston">
-
- <!--- add a third column to the query --->
- <CFSET nColumnNumber3 = QueryAddColumn(Employees, "Location", LocationArray)>
-
- <table cellspacing="2" cellpadding="2" border="0">
- <tr>
- <th align="left">Name</th>
- <th align="left">Phone</th>
- <th align="left">Location</th>
- </tr>
- <CFOUTPUT query="Employees">
- <tr>
- <td>#Name#</td>
- <td>#PhoneNo#</td>
- <td>#Location#</td>
- </tr>
- </CFOUTPUT>
- </table>
-
- <P><B>Note:</B> Because there are fewer elements under Phone than the other columns,
- QueryAddColumn added padding to this column in the query.</P>
-
-
- </BODY>
-
- </HTML>
-