Inserting multiple form fields into 1 DB table.
Hey everyone. I'm having this problem inserting multiple products into the products table using a form. here is the form.
===== Start of form ======
<cfparam name="URL.BusinessID" default="" />
<cfquery name="qBusiness" datasource="wyi2">
SELECT BusinessID, BusinessName
FROM Business
WHERE BusinessID = #URL.BusinessID#
</cfquery>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><cfoutput query="qBusiness">#BusinessName# Events</cfoutput></title>
<link href="css/wyi.css" rel="stylesheet" type="text/css" />
</head>
<body>
<cfform action="events_process.cfm?BusinessID=#BusinessID#" method="post">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td> </td>
<td align="center">BusinessID</td>
<td align="center">Discription</td>
<td align="center">Price</td>
</tr>
<tr>
<td>Sale 1</td>
<td><cfinput type="text" name="BusinessID_1" size="5" value="#URL.BusinessID#"></td>
<td><cfinput type="text" name="Discription_1" size="50"></td>
<td><cfinput type="text" name="Price_1" size="5"></td>
</tr>
<tr>
<td>Sale 2</td>
<td><cfinput type="text" name="BusinessID_2" size="5"></td>
<td><cfinput type="text" name="Discription_2" size="50"></td>
<td><cfinput type="text" name="Price_2" size="5"></td>
</tr>
<tr>
<td>Sale 3</td>
<td><cfinput type="text" name="BusinessID_3" size="5"></td>
<td><cfinput type="text" name="Discription_3" size="50"></td>
<td><cfinput type="text" name="Price_3" size="5"></td>
</tr>
<tr>
<td>Sale 4</td>
<td><cfinput type="text" name="BusinessID_4" size="5"></td>
<td><cfinput type="text" name="Discription_4" size="50"></td>
<td><cfinput type="text" name="Price_4" size="5"></td>
</tr>
<tr>
<td>Sale 5</td>
<td><cfinput type="text" name="BusinessID_5" size="5"></td>
<td><cfinput type="text" name="Discription_5" size="50"></td>
<td><cfinput type="text" name="Price_5" size="5"></td>
</tr>
<tr>
<td>Sale 6</td>
<td><cfinput type="text" name="BusinessID_6" size="5"></td>
<td><cfinput type="text" name="Discription_6" size="50"></td>
<td><cfinput type="text" name="Price_6" size="5"></td>
</tr>
<tr>
<td>Sale 7</td>
<td><cfinput type="text" name="BusinessID_7" size="5"></td>
<td><cfinput type="text" name="Discription_7" size="50"></td>
<td><cfinput type="text" name="Price_7" size="5"></td>
</tr>
<tr>
<td>Sale 8</td>
<td><cfinput type="text" name="BusinessID_8" size="5"></td>
<td><cfinput type="text" name="Discription_8" size="50"></td>
<td><cfinput type="text" name="Price_8" size="5"></td>
</tr>
<tr>
<td>Sale 9</td>
<td><cfinput type="text" name="BusinessID_9" size="5"></td>
<td><cfinput type="text" name="Discription_9" size="50"></td>
<td><cfinput type="text" name="Price_9" size="5"></td>
</tr>
<tr>
<td>Sale10</td>
<td><cfinput type="text" name="BusinessID_10" size="5"></td>
<td><cfinput type="text" name="Discription_10" size="50"></td>
<td><cfinput type="text" name="Price_10" size="5"></td>
</tr>
<tr>
<td> </td>
<td colspan="3" align="center">
<cfinput type="submit" name="eButton" value="Add all the events">
</td>
</tr>
</table>
</cfform>
</body>
</html>
======== End of form ==========
The database table "Products" has ProductID (Primary Key, Auto number), BusinessID, ProductDiscription, ProductPrice.
I wanted to add the products based on how many form rows where filled. I have tried a bunch of cfif tag to only insert if a cert form field is defined and not blank, but no go. I have searched the forums to find someone with a same problem...no go. Can any see what I'm doing wrong or am I making more work then is needed as far as the CF goes?
