I'm looking for some help with code that will take POST information from a form and insert it into a table, for multiple rows at a time.
The problem is, the amount of rows the form could have varies depending on how many the user chooses to submit. I have a javascript Add Row button that adds additional rows to an original one row.
Here is the javascript and form code:
<script>
function generateRow() {
var d=document.getElementById("div");
d.innerHTML+=" # <input name=\"varnum\" type=\"text\" id=\"food\" size=\"5\"/>
Desc: <input name=\"vardesc\" type=\"text\" size=\"30\" />
Instr by: <input name=\"varins\" type=\"text\" size=\"8\" />
£ <input name=\"varvalue\" type=\"text\" /size=\"8\" /><br>";
}
</script>
<h2>Create New Valuation</h2>
<h3>Step 2 - Add Variations</h3>
<p>Complete all fields in the form below</p>
<form action=\"add.php?action=submit_valuation_step2\" name=\"frmAddValuation\" method=\"post\" onsubmit=\"return validateForm3()\">
<table width=\"650\" border=\"0\">
<tr><td bgcolor=\"#CCCCCC\" valign=\"top\">Variations </td><td>
# <input name=\"varnum\" type=\"text\" size=\"5\"/>
Desc: <input name=\"vardesc\" type=\"text\" size=\"30\" />
Instr by: <input name=\"varins\" type=\"text\" size=\"8\" />
£ <input name=\"varvalue\" type=\"text\" /size=\"8\" /><br>
<div id=\"div\"></div>
<input type=\"button\" value=\"Add More Rows\" onclick=\"generateRow()\"/>
</td></tr>
</table><input type=\"submit\" name=\"submit\" value=\"Continue to Step 2\">
</form>
I guess what Im looking for is the php and INSERT query for dealing with an undetermined number of rows...some sort of array. Can anyone help?