I am creating a simple forum using the CodeIgniter.
I want to get latest topic for each category in Forum Home Page. What i want is like so-
It's OK for a category page to get latest topic, but I can't get for Home Page
My Controller for Home Page Category List -
class Category extends CI_Controller {
public function index()
{
$this->load->model('Category_model');
$data['categories'] = $this->Category_model->get_all_categories();
$this->load->view('forums/index', $data);
}
}
My Model -
class Category_model extends CI_Model {
function get_all_categories()
{
$get_categories = $this->db->get('categories');
return $get_categories->result_array();
}
}
DB Structure-
Topics
- topic_id
- topic_title
- topic_content
- topic_cat_id
Categories
- cat_id
- cat_name
- cat_description