The problem you are having is because of the database structure. Those
materials fields need to be in a different table with another field that
relates to the project. Any time you have a 1 to Many relationship like
these 20 materials to 1 project, it cries out for two tables.
Here is some example sql, on how you would get the records, if the table was
split into the two parts.

SELECT Projects.ProjectID, Projects.Description, Materials.Material
FROM Projects, Materials
WHERE Projects.ProjectID = #projectID#
AND Projects.ProjectID = Materials.ProjectID

This way all you have to do is insert into the Materials table a new entry
with the projectid and the material, that's it.
I hope that makes sense...

If it's too late to redesign the database, why not just cfparam all of the
form variables on the action page?

jon
----- Original Message -----
From: "Jen R" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, June 07, 2001 3:16 PM
Subject: Dynamic Variable Names


>
> Ok...I was recently sitting in a meeting with some people in my department
about an application I'm developing.  Seeing as I am *the* developer I could
really use some help.  It's an estimating/billing application.  There is a
possibility of twenty different lines for materials used and twenty slots
for it to go in the database.  Pretty simple.  I was just going to put in
twenty different drop down boxes for this, which is the way they wanted it
done.  Well, not every project will use 20 different materials.  Some might
use 2, some might use 10, and some might use 20.  My supervisor (who has
enough CF experience to make him dangerous sometimes) thought it looked
cluttered like that so he said we'll let you choose how many lines you want
for materials. "we can do that, no problem!" he says.  So I'm left to figure
out how "we" are going to do it.
>
> I have the form where they enter in how many lines they want, and I have
the form with that number of lines and corresponding fields.  Not a problem
yet, but now here's where I find my difficulty...  When I submit this form
to the database I now have to figure out how to do the SQL submit statement
where the number of variables is dynamic.  In my database I have the fields
"material1, material2, material3, material4,....material20" and can build
the first part of the insert statement using a CFLOOP, but when I come to
the Values() part of the insert...how do I dynamically create that.
>
> For example:  The user wanted 5 lines for materials.  On the form the user
fills out the boxes for material1, material2, material3, material4,
material5.  How do I dynamically create the Values('#form.material1#',
'#form.material2#', '#form.material3#', '#form.material4#',
'#form.material5#')?  I have tried the Evaluate function before and didn't
have too much luck.
>
> Suggestions?  It seems like the whole project hinges on this dynamic
variables problem.
>
> Thank you...thank you....thank you!
>
>
>
> ---------------------------------
> Do You Yahoo!?
> Yahoo! Mail Personal Address - Get email at your own domain with Yahoo!
Mail.
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to