【问题标题】:issue getting the edit page to display in Codeigniter让编辑页面显示在 Codeigniter 中的问题
【发布时间】:2015-02-18 17:54:21
【问题描述】:

由于某种原因,我无法终生显示编辑页面。不知道我做错了什么,我多次查看代码。当我单击编辑记录时,页面是空白的,并且没有出现错误消息。

这是模型的代码,我认为这就是它导致问题的原因。

public function update_employee($data,$id)
    {
        $this->db->where('id',$id);
        $this->db->update('employee_list',$data);
        return ($this->db->affected_rows() != 1 ) ? false:true;
    }
}

这是控制器的代码

public function  update_employee()
    {
        $id=$this->input->post('id');

        $data=array('Employee_Name'=>$this->input->post('Employee_Name'),

            'Employee_Number'=>$this->input->post('Employee_Number'));


        $result=$this->employee_model->update_employee($data); 
if($result > 0) 
        {
            $this->session->set_flashdata('msg',"Employee Records Updated Successfully");
            redirect('employee/list_employees');

        }
        else
        {

            $this->session->set_flashdata('msg1',"No changes Made in Employee Records");
            redirect('employee/list_employees');


        }
    }

【问题讨论】:

    标签: php html sql-server codeigniter-2


    【解决方案1】:

    你的函数有错别字?

     $data=array('Emplyee_Name'...
    

    也许应该是:

    $data=array('Employee_Name'...
    

    希望对你有帮助

    【讨论】:

    • 那不是我输入的以缩短代码
    • 抱歉,我在代码中删减了一些内容,以便在我输入时缩短它,我一定是错过了输入。问题仍然在于模型返回 ($this->db->affected_rows() != 1 ) 吗?假:真;
    • 返回 ($this->db->affected_rows() != 1 ) ?假:真;这一定是错误的
    • 或者不确定是否在控制器中
    【解决方案2】:

    我替换了 return ($this->db->affected_rows() != 1 ) ? false:true; 使用return print_r($data);,现在它可以工作了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多