Help Pleassssssssssse.
I have a CF web page form that loops 10 times to give my users the option to insert multiple, up to 10, truck loads of freight into my database at once. The problem here is that the loop requires the Primary Key "id" to tell the difference between the rows of text fields. "id" is the ELEMENT. So regarless of what the user inputs in the form, 10 records will be inserted into the database because that "id" is still defined for each row of input fields. This will cause the database to fill up fast with empty records.
I need to delete the records that don't have any data in the rest of the record except for the "id". For example. My users will always enter a date into the date text field in order to specify when a truck load is available. If that date field is Null, can I make that condition cause an CFIF statement to begin a query to delete the rest of the record on the actionpage?....and how might I do that. My action page's code is below
Thanks
Chris
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
-------
Begin Code
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
-------
<cfloop list="#form.updatelist#" index="id">
<cfquery name="insertLoads" datasource="ADOpenFreight"
>
INSERT INTO freight (
<cfif "form.dc" & id NEQ "">
dc,
</cfif>
<cfif "form.trailer" & id NEQ "">
trailer,
</cfif>
<cfif "form.terminal" & id NEQ "">
terminal,
</cfif>
<cfif "form.fromcity" & id NEQ "">
fromcity,
</cfif>
<cfif "form.fromstate" & id NEQ "">
fromstate,
</cfif>
<cfif "form.tocity" & id NEQ "">
tocity,
</cfif>
<cfif "form.tostate" & id NEQ "">
tostate,
</cfif>
<cfif "form.commodity" & id NEQ "">
commodity,
</cfif>
<cfif "form.length" & id NEQ "">
length,
</cfif>
<cfif "form.width" & id NEQ "">
width,
</cfif>
<cfif "form.height" & id NEQ "">
height,
</cfif>
<cfif "form.rate" & id NEQ "">
rate,
</cfif>
<cfif "form.weight" & id NEQ "">
weight,
</cfif>
<cfif "form.miles" & id NEQ "">
miles,
</cfif>
<cfif "form.contact" & id NEQ "">
contact,
</cfif>
<cfif "form.phone" & id NEQ "">
phone,
</cfif>
<cfif "form.notes" & id NEQ "">
notes
</cfif>)
VALUES (
<cfif "form.dc" & id NEQ "">
'#evaluate("form.dc" & id)#',
</cfif>
<cfif "form.trailer" & id NEQ "">
'#evaluate("form.trailer" & id)#',
</cfif>
<cfif "form.terminal" & id NEQ "">
'#evaluate("form.terminal"
& id)#',
</cfif>
<cfif "form.fromcity" & id NEQ "">
'#evaluate("form.fromcity"
& id)#',
</cfif>
<cfif "form.fromstate" NEQ "">
'#evaluate("form.fromstate
" & id)#',
</cfif>
<cfif "form.tocity" & id NEQ "">
'#evaluate("form.tocity" & id)#',
</cfif>
<cfif "form.tostate" & id NEQ "">
'#evaluate("form.tostate" & id)#',
</cfif>
<cfif "form.commodity" & id NEQ "">
'#evaluate("form.commodity
" & id)#',
</cfif>
<cfif "form.length" & id NEQ "">
'#evaluate("form.length" & id)#',
</cfif>
<cfif "form.width" & id NEQ "">
'#evaluate("form.width" & id)#',
</cfif>
<cfif "form.height" & id NEQ "">
'#evaluate("form.height" & id)#',
</cfif>
<cfif "form.weight" & id NEQ "">
'#evaluate("form.weight" & id)#',
</cfif>
<cfif "form.rate" & id NEQ "">
'#evaluate("form.rate" & id)#',
</cfif>
<cfif "form.miles" & id NEQ "">
'#evaluate("form.miles" & id)#',
</cfif>
<cfif "form.phone" & id NEQ "">
'#evaluate("form.phone" & id)#',
</cfif>
<cfif "form.contact" & id NEQ "">
'#evaluate("form.contact" & id)#',
</cfif>
<cfif "form.notes" & id NEQ "">
'#evaluate("form.notes" & id)#'
</cfif>)
</cfquery>
</cfloop>
<CFLOCATION URL="insertmultiple.cfm">