CodeIgniter Forums
displaying an image from a database - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: displaying an image from a database (/showthread.php?tid=46880)



displaying an image from a database - El Forum - 11-18-2011

[eluser]Unknown[/eluser]
Hi all,

I'm building a project of a shopping website. I want to view the product's image. my code is as follows:

in the controller:

Code:
public function monitor()
{  

  $this->load->helper('html');
// static entry of the parameter for the test
                $this->db->where('type',1);
  $screen['query']= $this->db->get('product');
  $this->load->view('screen_view',$screen);
}


in the view:

Code:
<?php    
    foreach($query->result() as $row)
{
    echo heading("name",1);
    echo img($row['image']);  
}
?>
But what i get is an error messsage :
Fatal error: Cannot use object of type stdClass as array in C:\xampp\htdocs\Qpixil\app\views\screen_view.php on line 63 (the line of echoing the heading).

I'm sure it's not a problem in the helper, bec. i tested by echo a static heading inside the foreach and it worked.

can anyone help