i have search alot and i have post somany times but i didnt get any proper answer.
This is my view page - View
here i have write a query for add fields dynamically for particular ref_no so help me for model and controller
<div id="login_form">
<?php echo form_open(base_url().'sample/invoice'); ?>
<label for="type" class="control-label">Type</label>
<div><?php echo form_input(array('id'=>'type','name'=>'type'));?></div>
<label for="ref" class="control-label">REF</label>
<div><?php echo form_input(array('id'=>'ref','name'=>'ref'));?></div>
<label for="title" class="control-label">TITLE</label>
<div><?php echo form_input(array('id'=>'title','name'=>'title'));?></div>
<div id="description"><p id="add_field">ADD DESCRIPTION</p></div>
<label for="doc" class="control-label">Support Doc</label>
<div><?php echo form_input(array('id'=>'doc','name'=>'attach','type'=>"file"));?></div>
<input id="btn_add" name="btn_add" type="submit" class="btn btn-primary" value="Save" />
</div>
<script>
var count = 0;
$(document).ready(function() {
$('p#add_field').click(function(){
count += 1;
var html='<strong>Description '+ count +'</strong>'+'<input id="description'+ count +'"name="description[]'+'" type="text" />'+'<input id="description'+ count +'"name="voucher_no[]'+'" type="text" />'+'<input id="description'+ count +'"name="price[]'+'" type="text" /><br />';
$('#description').append(html);
});
});
</script>
This is My Controller :
$data1 = array(
'invoice_type' => $this->input->post('type'),
'reference_no' => $this->input->post('ref'),
'des_title' => $this->input->post('title'),
);
$data2 = array(
'reference_no' => $this->input->post('ref'),
'description' => $this->input->post('des'),
);
$this->sample_model->insert_entry($data1, $data2);
This My MOdel :
function insert_entry($data1, $data2) {
$this->db->insert('myinvoice', $data1);
$this->db->insert('invoice_description', $data2);
}
What i want is insert mutiple descriptions for one reference number. myinvoice is parent table and invoice_description is child table when i insert single data its works perfectly but i want insert multiple descriptions
via Chebli Mohamed