All - I have searched and searched for help in the forums on this website and google and can't seem to find an answer.
What I want to do is insert multiple records in one table using one form with php, odbc, & access db.
The records that I am trying to add will have only one similar field, which will be the "Symbol" field. Let me explain what I mean.
Table fields:
ID, LE, Symbol, RIN
Sample records:
1250, L, 405, 12345
1251, E, 405, 12346
1252, L, 405, 12347
1253, L, 405, 12348
....
Add Rin form
InsertRin.php
What I want to do is insert multiple records in one table using one form with php, odbc, & access db.
The records that I am trying to add will have only one similar field, which will be the "Symbol" field. Let me explain what I mean.
Table fields:
ID, LE, Symbol, RIN
Sample records:
1250, L, 405, 12345
1251, E, 405, 12346
1252, L, 405, 12347
1253, L, 405, 12348
....
Add Rin form
Code:
<div id="oneColumn">
<h2>Add New RIN</h2>
<p><span class="required">*</span> = Required Fields</p>
<form id="ContactForm" action="insert_rin.php" method="post">
<label><span class="required">*</span> L/E:</label><input type="text" name="LE" />
<label><span class="required">*</span> Symbol:</label><input type="text" name="Symbol" />
<label>RIN:</label>
<input type="text" name="RIN[]" class="rinL" /><input type="text" name="RIN[]" class="rinR" />
<input type="text" name="RIN[]" class="rinL1" /><input type="text" name="RIN[]" class="rinR1" />
<input type="text" name="RIN[]" class="rinL1" /><input type="text" name="RIN[]" class="rinR1" />
<input type="text" name="RIN[]" class="rinL1" /><input type="text" name="RIN[]" class="rinR1" />
<input type="text" name="RIN[]" class="rinL1" /><input type="text" name="RIN[]" class="rinR1" />
<input type="submit" value="Submit" id="submitbutton130" class="button positive" />
</form>
</div>
InsertRin.php
Code:
<div id="oneColumn">
<h2>Add RIN</h2>
<?php
// create database connection
$conn=odbc_connect('cf','','');
if (!$conn)
{exit("Sorry, could not connect: " . $conn);}
foreach($_POST['RIN'] as $idx => $val)
{
$RIN = $val;
$le = $_POST['LE'][$idx];
$sym = $_POST['Symbol'][$idx];
$query = "INSERT INTO tblsymbols_rin (LE, Symbol, RIN) VALUES ('$RIN','$le','$sym')";
$rs = odbc_exec($conn,$query)
if(!rs)
{exit("Error, insert query failed. No record(s) added.");}
}
echo "<p>Records added.</p>";
odbc_close($conn)
?>
<p><a href="add_rin.php" class="button positive">Add Another RIN</a>
<a href="rins.php" class="button positive">Return to RINs List</a></p>
</div>