I am trying to make my bootstrap carousel dynamic in codeiginter here is what i have so far
Model Fucntion
function get_all_images(){
$query = $this->db->query("SELECT * FROM property AS p INNER JOIN property_images AS pi ON p.ID = pi.image_id
GROUP BY p.ID ORDER BY p.ID");
return $query->result_array();
}
My Controller:
public function view($id)
{
$query = $this->Property_m->get_all_images();
$res = $this->db->query($query);
$count = mysqli_num_rows($res);
$indicators = '';
$slides = '';
$counter = 0;
while($row=mysqli_fetch_array($res)) {
$image = $row['image_name'];
$title = $row['property_name'];
{
if ($counter == 0) {
$indicators .= '<li data-target="#slider-property" data-slide-to="' . $counter . '" class="active"></li>;';
$slides .= '<div class="item-active"><img src="<?php echo base_url()?>data/images/property_images/' . $image . '" alt="' . $title . '"/></div>';
} else {
$indicators .= '<li data-target="#slider-property" data-slide-to="' . $counter . '" class="active"></li>;';
$slides .= '<div class="item-active"><img src="<?php echo base_url()?>data/images/property_images/' . $image . '" alt="' . $title . '"/></div>';
}
$counter++;
}
$data['prop'] = $this->Property_m->get_property($id);
$data['title'] = 'Properties';
$data['content'] = 'property_view';
$this->load->view('templates/default/template', $data);
}
}
and finally my view
<div id="slider-property" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php echo $indicators; ?>
</ol>
<div class="carousel-inner">
<?php echo $slides; ?>
</div>
<a class="left carousel-control" href="#slider-property" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#slider-property" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
When i view this i get a content encoding error, could you please help me sort this out?