Welcome Guest, Not a member yet? Register   Sign In
How to pass variable value to another view?
#1

[eluser]Unknown[/eluser]
Hi Everyone,

I m stuck somewhere passing values between different view.
Let me explain my problem.

I have a controller: category.php
Code:
<?php
class Category extends Controller{
  function Category(){
    parent::Controller();
  }
  function index(){
    $data['catname'] = 'Development';
    $data['page'] = 'home';
    $this->load->view('include/template',$data);
  }
}

In this controller I am passing two value first is category name and second is page name which I will use in my template.
Here is my template code include/template.php
Code:
<?php
$this->load->view('header');
$this->load->view($page);?>

In my header view I am changing the value of catname variable.
header.php
Code:
<?php
$catname = "New Development";
?>

home.php
Code:
<?php
echo $catname;// Printing old value...
?>

Now problem is that when I am trying to print catname using my second view its showing me old value not updated one. So can anyone please suggest me how can I accomplish this.
I have tried GLOBAL varibale too but unable to solve this problem.

I am new to php and codeigniter so please suggest me.

Many thanks in advance.


Messages In This Thread
How to pass variable value to another view? - by El Forum - 01-10-2011, 02:47 PM
How to pass variable value to another view? - by El Forum - 01-10-2011, 03:59 PM
How to pass variable value to another view? - by El Forum - 01-10-2011, 04:04 PM
How to pass variable value to another view? - by El Forum - 01-10-2011, 06:53 PM
How to pass variable value to another view? - by El Forum - 01-10-2011, 10:56 PM
How to pass variable value to another view? - by El Forum - 01-10-2011, 11:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB