How do I prevent my loop from trying to insert an empty value into mySQL database? The form I am using has four rows automatically created. If they only fill in three rows than I get problems with the fourth row being empty. Below is my code that works fine as long as they don't leave a field empty.
<cfloop from="1" to="#form.numba#" index="idx">
<cfset getqty = form["qty" & idx]>
<cfset getitem = form["item" & idx]>
<cfset getunit = form["unit" & idx]>
<cfset gettotal = form["total" & idx]>
<cfquery name="insertItems" datasource="#application.dsn#">
INSERT into items
(orderID,
qty,
item,
unit,
total
)
VALUES(
<cfqueryparam value="#getoid#" CFSQLType="CF_SQL_INTEGER" >,
<cfqueryparam value="#getqty#" CFSQLType="CF_SQL_INTEGER" >,
<cfqueryparam value="#getitem#" CFSQLType="CF_SQL_VARCHAR" >,
<cfqueryparam value="#getunit#" CFSQLType="CF_SQL_INTEGER" >,
<cfqueryparam value="#gettotal#" CFSQLType="CF_SQL_INTEGER" >
)
</cfquery>
</cfloop>
Thanks in advance.