简体   繁体   English

读取工作,添加,编辑,删除不要在Grocery Crud库Codeigniter中

[英]Read works, add, edit, delete do not in Grocery Crud library Codeigniter

I have done the example and installed everything. 我已经完成了示例并安装了所有内容。

The read or display method of table works correctly, but whenever I try to add, delete or edit a registry a windows appears and say: 表的读取或显示方法可以正常工作,但每当我尝试添加,删除或编辑注册表时,都会出现一个窗口并说:

404 Page Not Found

The page you requested was not found.

Here is my Controller 这是我的控制器

class Welcome extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->model('grocery_CRUD_model');
        $this->load->database();
        $this->load->helper('url');
        $this->load->library('grocery_CRUD');
    }


    public function index()
    {
        $crud = new grocery_CRUD();

        $crud->set_theme('datatables');
        $crud->set_table('students');
        $crud->set_relation('class','class','class');
        $crud->display_as('name','Name of Student');
        $crud->set_subject('Students');
        $crud->columns('name','class','roll_no');
        $crud->add_fields('name','class','roll_no');
        $crud->required_fields('name','class','roll_no');
        $crud->unset_export();
        $crud->unset_print();
        $output = $crud->render();
        $this->load->view('home', $output);

    }

}

when i click ADD button URL becomes 当我点击添加按钮URL成为

http://localhost/index.php/add

what is missed? 错过了什么? i am new in codeigniter and Grocery Crud... 我是codeigniter和Grocery Crud的新手......

Create another function in Welcome controller and move all of the code from index() function to new function just like: Welcome控制器中创建另一个函数,并将所有代码从index()函数移动到新函数,如:

public function myFunction()
    {
        $crud = new grocery_CRUD();

        $crud->set_theme('datatables');
        $crud->set_table('students');
        $crud->set_relation('class','class','class');
        $crud->display_as('name','Name of Student');
        $crud->set_subject('Students');
        $crud->columns('name','class','roll_no');
        $crud->add_fields('name','class','roll_no');
        $crud->required_fields('name','class','roll_no');
        $crud->unset_export();
        $crud->unset_print();
        $output = $crud->render();
        $this->load->view('home', $output);

    }

And redirect your index() function to this method: 并将index()函数重定向到此方法:

public function index()
    {   
        redirect("welcome/myFunction");
    }

Access your grocery crud page at 访问您的杂货店crud页面

http://localhost/index.php/welcome/newFunction

Or simply 或者干脆

http://localhost/index.php/welcome

You're good to go now. 你现在很高兴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM