I have dynamic input data and i want to store Item name(Refer image:1)
data into the database in the same column like given in the database image (Refer image:2).
How do i do that in codeigniter?
I want to store dynamic input data of item name like given in the item_name column.
<?php
Class my_controller extends CI_controller{
public function my_method(){
$data = array(
'total_price' => $this->input->post('total_price'), //Total price of all item
'item_name' => $this->input->post('item_name') //Dynamic input value of item name
);
$result = $this->my_model->inser_item($data);
}
}
?>
<div>
<form action="<?php echo base_url(); ?>my_controller/my_method" method="post">
<input type="text" name="item_name[]" id="item_name">
<input type="text" name="total_price" id="total_price">
<button type="submit" name="submit">Submit</button>
</form>
</div>
Thanks in advance.
I don't know if I get it correctly, if you want to insert the item_name
values into a single table column, you could implode()
it :
...
$data = array(
'total_price' => $this->input->post('total_price'), //Total price of all item
'item_name' => implode(',', $this->input->post('item_name')) //Dynamic input value of item name
);
...