Welcome Guest, Not a member yet? Register   Sign In
How to create categories and associate them with posts
#4

I'm doing some tests, like counting how many posts are in a category. Unfortunately I can not get it running because it tells me it can not pick up the variable, but if I do "echo" me it prints correctly.

Anyway, I cleaned up everything and now only show all the results in the "love" category. How can I make the variable of all categories in place?

Controller:

PHP Code:
public function category($slug_category) {
        
$this->load->view('post/category');
    } 

Model
PHP Code:
public function countPostCat() {
 
       $this->db->like('id');
 
       $this->db->from('post');
 
       $this->db->where('slug_category''love');
 
       return $this->db->count_all_results();
 
   

Views
PHP Code:
(<?php echo $this->admin_model->countPostCat(); ?>
Reply


Messages In This Thread
RE: How to create categories and associate them with posts - by Marcolino92 - 09-16-2017, 02:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB