hi guys... i need your help... i want to create a page that asks for a user to input a number, and when submitted, it will create rows of textfields according to the user's input...
here's the code... (inventory.php)
<form method="POST" action="inventory1.php">
<p>Number of equipments:<br><input type="text" name="num" size=5></p>
<input type="submit" value="Go">
</form>
(inventory1.php)
<form method="POST" action="add_inventory.php">
<table>
<?php
for($i=0; $i<$num; $i++) {
echo "<tr><td><input type='text' name='field_a_[]/></td>";
echo "<td><input type='text' name='field_b_[]'></td>";
echo "<td><input type='text' name='field_c_[]'/></td>";
echo "<td><input type='text' name='field_d_[]'/></td>";
echo "<td><input type='text' name='field_e_[]'/></td>";
echo "<td><input type='text' name='field_f_[]'/></td></tr>";
}
?>
<tr>
<td><input type="submit" value="Next"></td>
</tr>
</table>
</form>
(add_inventory.php)
<?php
.
.
.
$field_a = $_POST['field_a'];
$field_b = $_POST['field_b'];
$field_c = $_POST['field_c'];
$field_d = $_POST['field_d'];
$field_e = $_POST['field_e'];
$field_f = $_POST['field_f'];
$num = $_POST['num'];
foreach($field_a as $key => $val) {
{
$sql="INSERT INTO inventory (field_a, field_b, field_c, field_d, field_e, field_f) VALUES ('".$val."','".$field_b[$key]."','".$field_c[$key]."','".$field_d[$key]."','".$field_e[$key]."','".$field_f[$key]."')";
mysql_query($sql) or die(mysql_error());
}
.
.
.
?>
now, when the textfield values are inserted in the table, it will only store the values of the 'field_a' field, the rest are left empty... what will i do???