> Would someone send me some code that demonstrates a two-
> dimensional array?
>
> I have this and need to pass another variable but don't know how:
>
> <CFSET ItemArray = ListToArray(#FORM.Item_id#)>
> <CFSET ArrayLength = #ArrayLen(ItemArray)#>
>
> <CFLOOP Index="LoopCount" from="1" to="#variables.ArrayLength#">
> <CFSET ItemOrdered = ItemArray[#LoopCount#]>
> <CFQUERY name="insertitems" datasource="#Application.DSN#">
> INSERT INTO recipe_item( recipe_id, Item_id)
> VALUES (#VARIABLES.MAXRecipeID#,#variables.ItemOrdered#)
> </cfquery>
> </cfloop>

Think of a 2 dimensional array as a spreadsheet - you can call the
information from the rows and the columns - the first entry being the row,
the second being the column.
Expanding on this, a 3 dimensional array is like having multiple sheets on
the file.
I could explain how more than 3 dimensions work, but it'd probably be a bit
of a mind-bender... Just try to visualise a 9 dimensional array, and see how
sane you remain <g>

An example might be the State and Zip code abbreviation (for all you
Americans);

StateArray[1][1]="New York";  StateArray[1][2]="NY";
StateArray[2][1]="California";StateArray[2][2]="CA";
etc.

So, when you're looping through it
<cfloop index="LoopCount" from=1 to="#ArrayLen(StateArray)#">
        <cfquery datasource="#application.DSN#">
                insert into recipe_item(State, Abbrev)
                values (#StateArray[LoopCount][1]#, #StateArray[LoopCount][2]#)
        </cfquery>
</cfloop>

I know it's not the same as your example, but I'm hoping this explains more
of what the functionality does

HTH

Philip Arnold
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to