Welcome Guest, Not a member yet? Register   Sign In
Problem when trying to display image from database
#1

[eluser]FabD[/eluser]
Hi,

I can't display images stored into a database. After searching on the forum, i have found some idea and I did it.

First the piece of code in the form/view file :
Code:
<img src="&lt;?php echo base_url() ?&gt;index.php/signal/marches/displayimage/&lt;?php echo $marches['MA_ID'] ?&gt;" border='0' align='left'/>;

which gives me in the source file for an Id equal to 1 :
Code:
<img src="http://localhost/gerico/index.php/signal/marches/displayimage/1" border='0' align='left'/>;

the function int the controller :
Code:
function displayimage(){    
    $Id = $this->uri->segment(4);
    echo 'ID ='.$Id;
    $image = $this->MMarches->getImage($Id);
    if (!is_null($image)) {
        header("Content-type: image/jpeg");
        print($image['0']['MA_PHOTO']);
    }        
}

but no ID displayed via the 'echo' statement.

and finally the function in the model :
Code:
function getImage($Id){
     $Q = $this->db->query("SELECT MA_PHOTO FROM GERICO.REF_MARCHES WHERE MA_ID=".$Id);
     if ($Q->num_rows() > 0){            
          $data = $Q->row_array();
        }
    $Q->free_result();    
     $str = $this->db->last_query();
     echo $str;
     print_r($data);
     return $data;        
}

but again, nothing is displayed. So I guess the the call the controller's function doesn't work. But I don't see what is wrong.

Can you help me ?


Messages In This Thread
Problem when trying to display image from database - by El Forum - 03-10-2009, 05:42 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 06:52 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 07:23 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 07:30 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 07:46 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 07:55 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 08:05 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 08:15 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 08:30 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 08:36 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 08:38 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 08:45 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 08:52 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 09:01 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 09:17 AM
Problem when trying to display image from database - by El Forum - 03-10-2009, 12:42 PM
Problem when trying to display image from database - by El Forum - 03-10-2009, 12:46 PM
Problem when trying to display image from database - by El Forum - 08-10-2010, 05:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB