Swapnil Phadke

Swapnil Phadke

  • NA
  • 1
  • 953

how to fetch images from database

Aug 11 2014 2:59 AM
I m beginner in codeignitor.my problem is when i fetch data from database all other data has fetched but image are not displayed.please proveide me code for how to fetch image from database.
model file code
<?php
class Car_model extends CI_Model
{
function getAllRecords()
{
$this->load->database();
$q = $this->db->get('cardetails');
if($q->num_rows() > 0)
{
return $q->result();
}
return array();
}
}
?>
controller file code
<?php
class Search extends CI_Controller {
function searchname()
{
$this->load->model("car_model");
$data['records'] = $this->car_model->getAllRecords();
$this->load->view('header_view');
$this->load->view('search',$data);
$this->load->view('footer_view');
}
}
?>
view file code
<?php
foreach($records as $row):
?>
<tr>
<td><img height="100" width="200" src="http://localhost/ci_user/images.'<?php=$row->mco_carimage?>.'
"/></td>
<td align="center"><?=$row->mco_carname ?></td>
<td align="center"><?=$row->mco_totalkm ?></td>
<td align="center"><?=$row->mco_price ?>&nbsp;Rs</td>
<td align="center"><?=$row->mco_insurance ?></td>
<td align="center"><?=$row->mco_fualtype ?></td>
</tr>
<?php
endforeach;
?>

Answers (1)