I've been losing sleep over this one and would appreciate anyone who can find the solution. I did a work-around that involves about 600 lines of code (it's insane, I know!) because I was out of time and had to deliver the product, but now I really need to make it proper. So...
It's the admin for a photo gallery. The user uploads any amount of photos into a temp directory via activex control. CFDIRECTORY reads the contents of the temp directory and outputs for each photo (using a loop, of course) a thumbnail and a text input box for the user to input a caption. To differentiate each caption, I've dropped in a counter that names the caption fields PhotoCaption1, PhotoCaption2, etc... Now, on the receiving end of this form I need to loop over each PhotoCaption and insert it into the database (as well as some other tasks). Now what I can't figure out is how to have one variable inside another one and have it be a variable itself. Perhaps looking at the code below will demonstrate what I mean. Theoretically, this code would work. But of course, CF melts down. *sigh*
[red]
[/red]
It's the admin for a photo gallery. The user uploads any amount of photos into a temp directory via activex control. CFDIRECTORY reads the contents of the temp directory and outputs for each photo (using a loop, of course) a thumbnail and a text input box for the user to input a caption. To differentiate each caption, I've dropped in a counter that names the caption fields PhotoCaption1, PhotoCaption2, etc... Now, on the receiving end of this form I need to loop over each PhotoCaption and insert it into the database (as well as some other tasks). Now what I can't figure out is how to have one variable inside another one and have it be a variable itself. Perhaps looking at the code below will demonstrate what I mean. Theoretically, this code would work. But of course, CF melts down. *sigh*
[red]
Code:
<cfdirectory action="LIST" directory="C:\[URL unfurl="true"]www\mydomain.com\photos\photofiles\temp"[/URL] name="temp_photos" filter="*.jpg">
<cfoutput query="temp_photos">
<cfset theNumber = theNumber + 1>
<cfquery name="insert_photo" datasource="mydsn">
INSERT INTO Photo (EventID, PhotoCaption)
VALUES (#EventID#, '#Form.PhotoCaption.#theNumber##')
</cfquery>
</cfoutput>