I am using codeIgniter and I am trying to pass an array of data. I have written like this:
$data['username']="Dumbo";
I also wrote this:
$data['shouts']=$this->Musers->getShout(); // retrieve data from table
Then I write:
$this->load->view("welcome_message", $data);
In view page, I wrote:
<?php echo $username;
foreach ($shouts as $shout)
{
echo $shout->shout;
echo '<br>';
echo $shout->timeStamp;
}
?>
Problem is that while the view did retrieve data from table and display results in view page, an error came up for $data['username'] saying, "Undefined variable: username"
Why is that? The $data['username'] is already defined! Or what did I do wrong?