php – 读取工作,添加,编辑,删除不要在Grocery Crud库Codeignite
发布时间:2020-12-13 16:53:06 所属栏目:PHP教程 来源:网络整理
导读:我已经完成了示例并安装了所有内容. 表的读取或显示方法可以正常工作,但每当我尝试添加,删除或编辑注册表时,都会出现一个窗口并说: 404 Page Not FoundThe page you requested was not found. 这是我的控制器 class Welcome extends CI_Controller { public
我已经完成了示例并安装了所有内容.
表的读取或显示方法可以正常工作,但每当我尝试添加,删除或编辑注册表时,都会出现一个窗口并说: 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','roll_no'); $crud->add_fields('name','roll_no'); $crud->required_fields('name','roll_no'); $crud->unset_export(); $crud->unset_print(); $output = $crud->render(); $this->load->view('home',$output); } } 当我点击添加按钮URL成为 http://localhost/index.php/add 错过了什么? 解决方法
在Welcome控制器中创建另一个函数,并将所有代码从index()函数移动到新函数,如:
public function myFunction() { $crud = new grocery_CRUD(); $crud->set_theme('datatables'); $crud->set_table('students'); $crud->set_relation('class',$output); } 并将index()函数重定向到此方法: public function index() { redirect("welcome/myFunction"); } 访问您的杂货店crud页面 HTTP://localhost/index.php/welcome/newFunction 或者干脆 HTTP://localhost/index.php/welcome 你现在很高兴. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |