• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a bit of logic help wanted

I have a variable in my controller that I call three times on my home page but I would like it to have different articles showing up on my page rather than have the same items three times. Here is the code
$data['post'] = $this->MPosts->getAllActivePosts();
. So have been retrieving the active post on website with some with pictures and some just the headings. What I would like to have is a start and limit so that there is a continuation of the mysql query on the three articles on the page because its news so I cannot have the same four topics showing. So do I have to perform the same query with different parameters or do I have to use a different variable for my articles?

You want to look in your model and update the query in getAllActivePosts(). Post this function if you need help with that.

here is the controller
function index()
    $data['cats'] = $this->MCats->getTopCategories(); //we will replace soon!
    $data['title'] = "Shout-Africa";
    $data['main'] = 'public_home';
    $data['featured'] = $this->MPosts->getAllFeaturedPosts();
    $data['post'] = $this->MPosts->getAllActivePosts();
    $data['comms'] = $this->MComments->getLatestComments();    

and here is the model
function getAllActivePosts(){
     $data = array();
     $this->db->where('status', 'published');
     $Q = $this->db->get('posts');
     if ($Q->num_rows() > 0){
       foreach ($Q->result_array() as $row){
         $data[] = $row;
    return $data;
I hope that helps.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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