I'm using codeigniter. I have a form which can save multiple data at once. there is a dropdown with data in database. Now I want to take this value and save its id as a foreign key as my table. But it doesn't work.
view
<form class="form-inline" role="form" id="frmadd" action="<?php echo base_url() ?>index.php/boq_controller/create" method="POST">
<?php
$attributes = 'class = "form-control" id = "user" name="boq[<?php echo $i ?>][user]"';
echo form_dropdown('user',$user, set_value('user'), $attributes);?>
<?php
$i =0;
for($i=0;$i<10;$i++){?>
<tr class="txtMult">
<td><input type="text" name="boq[<?php echo $i ?>][work_product_id]" class="form-control" id="work_product_id" placeholder=""></td>
<td><input type="text" name="boq[<?php echo $i ?>][work_item_description]" class="form-control" id="work_item_description" placeholder=""></td>
<td><input type="text" name="boq[<?php echo $i ?>][quantity]" id="" class="form-control val1" /></td>
<td><select style=" height: 33px; width: 102px; border-radius: 2px;" name="boq[<?php echo $i ?>][unit]">
<option value="" selected> </option>
<option value="cube">cube</option>
<option value="sq.ft">sq.ft</option>
<option value="Cwts">Cwts</option>
<option value="Gal" >Gal</option>
</select></td>
<td><input type="text" name="boq[<?php echo $i ?>][rate]" class="form-control val2"/></td>
<td><input type="text" name="boq[<?php echo $i ?>][laboure_hrs]" id="" class="form-control val3" /></td>
<td><input type="text"name="boq[<?php echo $i ?>][laboure_cost]" id="" class="form-control val4"/></td>
<td><input type="text" name="boq[<?php echo $i ?>][others]" class="form-control" id="others" placeholder=""></td>
<td>
<span class="multTotal">0.00</span><input type="text" id="txtmultTotal" name="boq[<?php echo $i ?>][txtmultTotal]">
<!-- <input type="text" class="multTotal" placeholder="0.00">-->
</td>
</tr>
<?php }?>
Model
public function create()
{
foreach($_POST['boq'] as $boq)
{
$_POST['user'];
$this->db->insert('boq', $boq);
}
}
controller
public function index()
{
$data['user'] = $this-> boq_model ->get_user();
$this->load->view('admin_include/header');
$this->load->view('boq/boq',$data);
}