I want to insert data from dynamic page to mysql database.
I am having master detail table with foreign key between them.
master table ‘bill_of_material’ & its column are "bom_id, product_id, product_qty, unit_id "
detail table ‘bill_of_material_detail’ & its column are "bom_id, item_id, item_qty, unit_id "
I have developed dynamic page which adds rows. following are the code.
[php]
<?php $options_item=""; $units_set_item = get_all_items(); while ($row_item=mysql_fetch_array($units_set_item)) { $value_item = $row_item ["item_id"]; $id_item=$row_item["item_name"]; $thing_item=$row_item["item_code"]; $br ="("; $br1=")"; $item =$id_item." ".$br.$thing_item.$br1; $options_item.="".$item.''; } ?> <form action="create_item.php" method="post">
<p>
Product :
<SELECT NAME=item_primery_unit>
<OPTION VALUE=0>
<?php echo $options_item;?>
</SELECT>
</p>
<p> Product qty :
<input type="text" name="item_name" value="" />
</p>
<?php
$options="";
$units_set = get_all_units();
while ($row=mysql_fetch_array($units_set))
{
$value = $row ["unit_id"];
$id=$row["unit_name"];
$thing=$row["unit_abbr"];
$br ="(";
$br1=")";
$unit=$id." ".$br.$thing.$br1;
$options.="<OPTION VALUE=\"$value\">".$unit.'</option>';
}
?>
<p>
Product unit :
<SELECT NAME=item_primery_unit>
<OPTION VALUE=0>
<?php echo $options?>
</SELECT>
</p>
<p align= "center">
<INPUT type="button" value="Add Row" onclick="addRow('dataTable')" />
<INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" />
<!-- <INPUT type="button" value="Save Data" onclick="SaveRow('dataTable')" /> -->
<p/>
<TABLE id="display_header" BORDER="2" CELLPADDING="4" CELLSPACING="2" WIDTH="870">
<tr>
<td WIDTH="70">Row</td>
<td WIDTH="200">Source item</td>
<td WIDTH="200">Source item qty</td>
<td WIDTH="200">source item unit</td>
</tr>
</TABLE>
<TABLE id="dataTable" BORDER="2" CELLPADDING="4" CELLSPACING="2" WIDTH="870">
<TR>
<TD WIDTH="70"><INPUT type="checkbox" name="chk"/></TD>
<td WIDTH="200"><SELECT NAME=item_primery_unit>
<OPTION VALUE=0>
<?php echo $options_item;?>
</SELECT>
</td>
<td WIDTH="200"> <input type="text" name="item_name" value="" /></td>
<td WIDTH="200" ><SELECT NAME=item_primery_unit>
<OPTION VALUE=0>
<?php echo $options?>
</SELECT>
</td>
</TR>
</TABLE>
<input type="Submit" name="submit" value="Save Item" />
</form>
[/php]