[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="<?php echo base_url() ?>index.php/signal/marches/displayimage/<?php echo $marches['MA_ID'] ?>" 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 ?