controller
Code:
public function category() {
//Get Article View
$data['articles'] = $this->Article_model->get_categories_t('id','DESC');
//Get Articles
//Load View
$this->load->view('cate', $data);
}
model
Code:
public function get_categories($order_by = null, $sort = 'DESC', $limit = null, $offset = 0) {
$this->db->select('a.*, c.name as category_name');
$this->db->from('articles as a');
$this->db->join('categories AS c', 'a.category_id = c.id ','LEFT');
if($limit != null) {
$this->db->limit($limit, $offset);
}
if($order_by != null) {
$this->db->order_by($order_by, $sort);
}
$query = $this->db->get();
return $query->result();
}
view
Code:
<?php foreach ($articles as $article) : ?>
<div class="blog-grid-col"> <!--movie video block-->
<div class="blog-grid-content">
<div class="head-tags red-bg">
<span class="head-title"><?php echo $article->category_name; ?></span>
</div>
<div class="blog-grid-img block-height">
<a href="<?php echo base_url (); ?>articles/view/<?php echo $article->id; ?>">
<a href="<?php echo base_url (); ?>articles/view/<?php echo $article->id; ?>"><img src="assets/movies/<?php echo $article->image; ?>" /></a>
</a>
</div>
<div class="figcaption dark-bg"> <!--movie-video-block-hover-->
<div class="bg-dark-shadow"></div>
<div class="head-small-tags red-small-bg">
<i class="fa fa-video-camera fa-lg"></i>
</div>
<div class="text-blog-grid-2 block-height">
<a href="<?php echo base_url (); ?>articles/view/<?php echo $article->id; ?>"><h5><?php echo $article->title; ?></h5></a>
<p class="readmore">
<a href="<?php echo base_url (); ?>articles/view/<?php echo $article->id; ?>" type="button" class="btn btn-lg btn-primary btn-block">Read More</a>
</p>
<div class="movies-foot">
<ul>
<li class="rate">
<a href="#"><i class="fa fa-star"></i></a>
<a href="#"><i class="fa fa-star"></i></a>
<a href="#"><i class="fa fa-star"></i></a>
<a href="#"><i class="fa fa-star"></i></a>
<a href="#"><i class="fa fa-star"></i></a>
</li>
<li class="like-rate">
<a href="#"><i class="fa fa-heart"></i></a>
<a href="#"><i class="fa fa-share-square"></i></a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
result show all categories on display not for selected only
how to do this any one solve this