nellie 发表于 2017-3-11 15:58:32

点添加按钮不执行数据库操作,出现以前编辑的页面

本帖最后由 nellie 于 2017-3-11 16:22 编辑

以前编辑的:
class Apartment extends CI_Controller
{
      //添加部门
      public function add_apart()
      {
                $this->load->helper('form');
                $this->load->view('add_apart.html');
      }
      
      //添加动作
      public function add()
      {
                $this->load->library('form_validation');
                $status = $this->form_validation->run('apart');
                if($status){
                        echo "添加";
                } else {
                        $this->load->helper('form');
                        $this->load->view('add_apart.html');
                }
               
      }
}

现在编辑的:
class Apartment extends CI_Controller
{
      //添加部门
      public function add_apart()
      {
                $this->load->helper('form');
                $this->load->view('add_apart.html');
      }
      
      //添加动作
      public function add()
      {
                $this->load->library('form_validation');
                $status = $this->form_validation->run('apart');
                if($status){
                        $data = array(
                              'bname' => $_POST['bname']
                              );
                        $this->load->model('apartment_model','apart');
                        $this->apart->add($data);
                } else {
                        $this->load->helper('form');
                        $this->load->view('add_apart.html');
                }
               
      }
}
现在点击按钮后,出现的是“添加”,数据没有添加到数据库,各位大神帮我找找问题,我完全不知道该怎么做了

nellie 发表于 2017-3-11 16:23:04

问题自己解决了,是重名了
页: [1]
查看完整版本: 点添加按钮不执行数据库操作,出现以前编辑的页面