I want letting user add dynamic inputs and save those values in the database. But with this code only one value save to the database. How can I save all values to the database
function error(){
if ($this->input->post('mytext')) {
$attain = $this->input->post('mytext', true);
$data2=array(); //<-initialize
foreach ($attain as $i => $a) { // need index to match other properties
//append array
$data2[] = array(
'mytext' => $a,
'projectname'=> $this->input->post('projectname'),
);
//for multiple entry in same table
$this->db->insert_batch('projectem', $data2);
redirect('Select_ctrl2/ModalAddEmployeesProject');
}
}
}