controllers/Cspages.php
public function index()
{
$this->load->helper('url');
$this->load->model('gallery_model');
$pic_unique_id = 18; // slider
$data['pic'] = $this->gallery_model->get_picture($pic_unique_id);
$this->load->view('index', $data);
}
views/index.php
<?php foreach($pic as $pic_item): ?> <img src="<?php echo base_url('assets1/images/slider/'.$pic_item->pic_item );?>"> <?php endforeach;?>
models/gallery_model.php
public function get_picture($pic_unique_id)
{
$query = $this->db->get_where('galleries_pictures', array('picture_unique_id' => $pic_unique_id));
return $query->result();
}
Now the result is:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$pic_item
Filename: views/index.php
Line Number: 214
I wonder how to fix this result so that I could see the picture appears on my view.