I have this simple code that where I am trying to display the name ana from the model in the view. Here is the simple code for the controller, model and the view.I get the error code: Message: Undefined variable: celebrity Filename: views/Stardisplay.php
Thanks
<?php
class Starcontroller extends CI_Controller {
function __construct()
{
parent::__construct();
}
function guess()
{
$this->load->model('Starmodel');
$newstarr = $this->Starmodel->lookup();
$this->load->view('Stardisplay',$celebrity);
}
}
?>
<?php
class Starmodel extends CI_Model{
function __construct()
{
parent::__construct();
}
public function lookup(){
$celebrity = "Anna";
return $celebrity;
}
}
?>
<html>
<head></head>
<body>
<?php
echo $celebrity;
?>
</body>
</html>
I have made the changes, but still it won’t display the name “Anna”.
I thought that in the code I need to pass to the view Stardisplay the value of the variable $celebrity
Maybe I am not doing something right:
In the codeigniter controllers folder I have a controller welcome.php with the function:
public function index()
{
$this->load->view('Stardisplay.php');
}