How to pass parameters in index function in codeigniter

后端 未结 12 1873
傲寒
傲寒 2020-12-14 03:02

here\'s an example of url: http://www.example.com/search/search-keyword

I am trying to make this work, I removed the index.php using .htaccess, search is the contro

12条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-14 03:32

    Thank you. This code works for me. If parameter is a number

    Or you need to use a route $route['search/(:any)'] = 'search/index/$1';
    

    However, If the parameter is a string (http://[::1]/note/getnote/index/fg => http://[::1]/note/getnote/fg). I use _remap() like this code.

    class Getnote extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->library('image_lib');
    }
    
    public function index(){
    
    }
    
    public function _remap($keyname)
    {
        $this->load->model('Laydb');
        $data = $this->Laydb->getNote($keyname);
        $proListArray['patitle'] = "Edit notepad";
    
        $this->load->view('top', $proListArray);
        $this->load->view('editblog', $data);
        $this->load->view('bottom');
    }
    

    }

提交回复
热议问题