Create another function in the controller Welcomeand move all the code from the function index()to a new function, for example:
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 the function index()to this method:
public function index()
{
redirect("welcome/myFunction");
}
http://localhost/index.php/welcome/newFunction
http://localhost/index.php/welcome
.