I just started to learn CodeIgnighter and I face lot many problems.
I made one Controller and one view which is given below.
This is My Controller
<?php
class Blog extends CI_Controller{
function __construct() {
parent::__construct();
}
function index(){
$data['title'] = "My First Blog";
$data['heading'] = "My Blog Heading";
$data['query'] = $this->db->get('entries');
$this->load->view('blog_view' ,$data);
}
}
?>
This is my View.
<html>
<head>
<title><?=$title?></title>
</head>
<body>
<h1><?=$heading?></h1>
<?php foreach ($query->result() as $row): ?>
<h3><?=$row->$title?></h3>
<p><?=$row->$body?></p>
<hr>
<?php endforeach;?>
</body>
</html>
When I execute this so I get this error.
PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$My First Blog
Filename: views/blog_view.php
Line Number: 9
Now I don’t know what is wrong in this code.
remove the “$” from the foreach variables: