how to update form data in codeigniter

后端 未结 3 1856
感情败类
感情败类 2021-01-14 14:03

I am new in codeigniter.

I am using codeigniter for this project. I have not getting how to update form data in the database. I have inserting,showing data in the dat

相关标签:
3条回答
  • 2021-01-14 14:34

    Just by having a quick look, I can see you're not passing anything to the $data in your entry_update1 function;

    public function entry_update1($id) {
    
        $this->db->where('id', $id);
        $this->db->update('user', $data);
    
    }
    

    You're trying to update 'user' with $data, but you haven't set $data.

    0 讨论(0)
  • 2021-01-14 14:40

    You have to run update query this way in CodeIgniter.

            public function entry_update1($id,$data) {
    
                $this->db->set($data);
                $this->db->where('id',$id);
                $update = $this->db->update('user');
                if($update)
                {
                    return true;
                }
                else
                {
                   return false;
                }
    
             }
    
    0 讨论(0)
  • 2021-01-14 14:44

    You are only passing $id in

    $this->usermodel->entry_update1($get['id']);

    and in function u did

    public function entry_update1($id) {
        $this->db->where('id', $id);
        $this->db->update('user', $data);
    }
    

    so you have to pass $data also in you function call

    $this->usermodel->entry_update1($get['id'], $data);

    public function entry_update1($id, $data) {
        $this->db->where('id', $id);
        $this->db->update('user', $data);
    }
    
    0 讨论(0)
提交回复
热议问题