oiram16
oiram16

Reputation: 95

How can I pass arguments from view to controller?

How can I pass arguments from view to controller? Hi everybody! I'm working in project but I have a problem. I want to pass one argument from my view to my controller and after use this variable for get a result of my database. my view:

<? $gCC = $this->getCustomer($gQ['id_u']);
foreach($gCC as $gC): ?>
Nombre<br />
Empresa<br />
<i class="fa fa-envelope" aria-hidden="true"></i> [email protected]
<? endforeach; ?>

my controller

$data['getCustomer'] = $this->generals->getCustomer($id);

I grateful for your help

Upvotes: 1

Views: 63

Answers (1)

Harsh Barach
Harsh Barach

Reputation: 957

You can use anchor tag to pass single or multiple arguments in your view.

<a href="http://example.com?test=1">dummy_name</a>

You can get value of test parameters by GET method in your controller.

$this->input->get('test'); //gives you 1 in your controller

You can also pass the parameters by segments in view.

<a href="http://example.com/test_1/test_2/test_3/test_4">dummy_name</a>

You can get value by URI segments in your controller.

$this->uri->segment(1); //gives you test_1 in your controller
$this->uri->segment(2); //gives you test_2 in your controller
$this->uri->segment(3); //gives you test_3 in your controller
$this->uri->segment(4); //gives you test_4 in your controller

Upvotes: 1

Related Questions