簡體   English   中英

讀取工作,添加,編輯,刪除不要在Grocery Crud庫Codeigniter中

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

我已經完成了示例並安裝了所有內容。

表的讀取或顯示方法可以正常工作,但每當我嘗試添加,刪除或編輯注冊表時,都會出現一個窗口並說:

404 Page Not Found

The page you requested was not found.

這是我的控制器

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);

    }

}

當我點擊添加按鈕URL成為

http://localhost/index.php/add

錯過了什么? 我是codeigniter和Grocery Crud的新手......

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);

    }

並將index()函數重定向到此方法:

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

訪問您的雜貨店crud頁面

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

或者干脆

http://localhost/index.php/welcome

你現在很高興。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM