Dynamic input values doesn't save in the databsae with codeigniter

后端 未结 1 602
一向
一向 2021-01-26 12:27

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

相关标签:
1条回答
  • 2021-01-26 12:45
    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');
            }
        }
      }
    
    0 讨论(0)
提交回复
热议问题