Search code examples
phpcodeigniter-2

How to pass parameters to Codeigniter controller from view page


Hi I need to pass variable parameters to codeigniter controller without click function any link from view page. I have no idea how to pass data to controller from view with out click anything.

My view page name is rows.php, In view page I had variable as below

$rows = 10;

this rows value I need to send to controller, if I send this to controller will display data as per parameter.

My Controller

public function getRows($parameter)
{
after query
$this->load->view('rows',$data);
}

I would appreciate your help.


Solution

  • You can using helper without any clicks.

    Helper

     //some_helper
     function abc($b)
     { 
       $a=$b-10;
       return $a;
     }
    

    View

     $this->load->helper("some_helper");  //note that helper file name always should be postfixed by '_helper'
    
     abc(20);