1

I am trying to pass a value from a view to a controller then to a view, which does not work for a reason, here is my view link that passing the value

<a href="<?php echo site_url('social_controller/load_modal/'.$row->PageFbPageID.''); ?>">More</a>

Here is my controller

function load_modal() {
            $this->load->helper('url');
            $term = $this->uri->segment(3);
            $this->load->view('/modals/fetch_modal',$term);


        }

and here is my fetch_modal view

<? 
echo $term;
?>

when i click More, the link actually has the value i need in the uri but i can not seem to pass it to the controller and then to my view , i am getting a white page only.

2 Answers 2

4

What if you first assign it in an array like this:

$data['term'] = $this->uri->segment(3);

and then pass it like this:

$this->load->view('/modals/fetch_modal',$data);

and in your view you access it like this:

<? 
echo $term;
?>
Sign up to request clarification or add additional context in comments.

Comments

1

You should put the $term variable in an array and then give it a key. That key will be the name of the variable into your view file.

//controller 
$this->load->view('/modals/fetch_modal',array('uri_term'=>$term));

//view 
var_dump($uri_term);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.