Link to home
Start Free TrialLog in
Avatar of PatrickMacC
PatrickMacC

asked on

dynamically building a select statement in coldfusion.

Working away on a little CRM type tool and I am a little stumped.

here is the issue I have.

Page1.cfm
asks for number of lines to work with (called portnum)

Calls page2.cfm portnum is passed over in a session variable

I loop on the form to show a input field for each line
<cfloop from="1" to="#session.portingfields.portnum#" index="counter">
  <cfoutput>
           	<cfinput type="text" name="number_#counter#" value="" size="8"><br>
  </cfoutput>
</cfloop>

Open in new window

and it calls writelines.cfm on submit

my issue is how to write it out to the sql after the person enters the details.   I am thinking that i build the insert string in writelines.cfm on the fly.  Am I right in this thinking or is their an easier way ?

thanks
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

You can access

#form.fieldnames# to get the fieldnames

e.g.

<cfloop item="fname" collection="#form#">
<cfoutput>#fname# - #form[fname]#<br></cfoutput>
</cfloop>


Use this information to build select statement

ASKER CERTIFIED SOLUTION
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial