简体   繁体   中英

passing a parameter from view to controller

i'm using Smarty and PHP.

I want to pass some parameter from the view to the controller

View

<dd><a href="{site_url()}admin/reloadConditions">Pre Registrado</a></dd>

Controller

public function reloadConditions($cond){
    // some code
}

I want to send for example the parameter "1", and tried different ways of doing like:

View

<dd><a href="{site_url()}admin/reloadConditions/1">Pre Registrado</a></dd>

But nothing seems to work. Is there any chance to do this?

Passing argumento get to function:

url: admin/reloadConditions/1

function index($id)
{
  echo $id; // output 1
}

Guide : http://ellislab.com/codeigniter%20/user-guide/general/controllers.html

or

function index()
{
  // admin/reloadConditions/1
  // admin = 1
  // reloadConditions = 2

  echo $this->uri->segment(3); // catch third parameter in url
}

Guide : http://ellislab.com/codeigniter%20/user-guide/libraries/uri.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM