Welcome Guest, Not a member yet? Register   Sign In
how to get the controller class function's returning value in views
#1

[eluser]Unknown[/eluser]
Hi, I am new in CI. And I am liking it. But I am still in confused about so many problems. right now I am facing this one problem is that When I write a function in CI Controller Class which returns a value. Now I want to output this returning value in a specific div of my views. When I do not return the data from the function, rather, just simply write echo in the function it shows the data on the top left corner of the screen. What I basically want is just get the function's returning value in a variable and print it in a specific div of mine. Which is pretty simple I know but its giving me huge problem.
#2

[eluser]CroNiX[/eluser]
Code:
//Controller
$data['page_h1'] = 'This is my h1'; //access as $page_h1 in your view
$this->load->view('your_view_file', $data);

Code:
//View (/application/views/your_view_file.php)
<div><h1>&lt;?php echo $page_h1; ?&gt;</h1></div>
#3

[eluser]Unknown[/eluser]
Hey Dude!!

Thank You very much, this really worked :-)




Theme © iAndrew 2016 - Forum software by © MyBB