Welcome Guest, Not a member yet? Register   Sign In
In Model how to select all last data starting from 5th row ?
#1

For examle there is 10 rows in table. My issue is how to fetch all data but starting from 5th row and 4 3 2 1 and so on?
Below code works but only with id numbers. so when my datas in table id will be mixed up like 50 46 42 40 and so on that code wont work.

Code:
public function fetch_data() {
         
       $maxid=5;
       
     
       $this->db->where('site_id <',$maxid);
       $this->db->order_by('site_id', 'DESC');
       $query = $this->db->get("sites");

       if ($query->num_rows() > 0) {
           foreach ($query->result() as $row) {
               $data[] = $row;
           }
           return $data;
       }
       return false;
       
  }
Reply


Messages In This Thread
In Model how to select all last data starting from 5th row ? - by paju89 - 12-06-2014, 04:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB