the scenario I was describing) in that I could use a structure and break
it apart to insert data in individual rows using the code below ??
Tim
-----Original Message-----
From: Dick Applebaum [mailto:[EMAIL PROTECTED]
Sent: Friday, September 10, 2004 10:14 AM
To: CF-Talk
Subject: Re: inserting structure data into a database
On Sep 10, 2004, at 6:37 AM, Tim Laureska wrote:
> OK ... so much for a structure in this case ... now onto the challenge
> of creating the loop coding you reference
>
> I'm not sure where I was convinced to go the structure route... If I
> may ask, what is a typical scenario when you DO use a structure?
>
>
Here's a modified example from the CF docs:
Looping through structures
You can loop through a structure to output its contents, as shown in
the following example:
<!--- Create a structure and set its contents --->
<cfset departments=structnew()>
<cfset val=StructInsert(departments, "John", "Sales")>
<cfset val=StructInsert(departments, "Tom", "Finance")>
<cfset val=StructInsert(departments, "Mike", "Education")>
<!--- Build a table to display the contents --->
<cfoutput>
<table cellpadding="2" cellspacing="2">
<tr>
<td><b>Employee</b></td>
<td><b>Department</b></td>
</tr>
<!--- Use cfloop to loop through the departments structure.
The item attribute specifies a name for the structure key. --->
<cfloop collection=#departments# item="person">
<cfquery name=InsertDept ....>
INSERT INTO myTable
(
Person,
Department
)
values
(
#person#,
#Departments[person]#
)
</cfquery>
<tr>
<td>#person#</td>
<td>#Departments[person]#</td>
</tr>
</cfloop>
</table>
</cfoutput>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]