• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
News Postal Home Page

I am currently working on a news portal using CI3,
backend is ready and no ideas with home page,how can i get posts in home page from certain category,and display as blocks as in screenshots.Help will appreciate,since this is my first projects on codeigniter.

This is one way of doing it, depends on how your database and tables are setup.

PHP Code:
public function getAllPostsByCategory($categoryId)
   $data = [];
   $query $this->db->get('posts');
   if ($query->num_rows() > 0)
       foreach ($query->result_array() as $row)
           $data[] = $row;

   return $data;

You need to have a category_id in your posts table for this to work.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.