Welcome Guest, Not a member yet? Register   Sign In
Pagination through search results
#3

[eluser]Thorpe Obazee[/eluser]
Code:
function search($limit, $offset = FALSE)
    {
    
        $this->db->select('jobs.id as job_id, jobs.job_name, jobs.job_title as job_title, jobs.job_content, jobs.job_author, jobs.job_posted as job_posted, jobs.cat_id, jobs.job_status, cats.id as cat_id, cats.cat_title');
        $this->db->from('jobs');
        $this->db->join('cats','cats.id = jobs.cat_id');
        
        if (isset($this->keyword))
        {
            $this->db->like('jobs.job_title',$this->keyword);
        }
        
        if ($offset)
        {
            $this->db->limit($limit,$offset);        
        }
        else
        {
            $this->db->limit($limit);        
        }
        
        $this->db->order_by('job_posted');
        
        $query = $this->db->get();
        
        return $query;
    
    }

    function count_result()
    {
    
        $this->db->select('count(jobs.id) as job_count');
        $this->db->from('jobs');
        $this->db->join('cats','cats.id = jobs.cat_id');
        
        if (isset($this->keyword))
        {
            $this->db->like('jobs.job_title',$this->keyword);
        }
        
        $this->db->order_by('job_posted');
        
        $query = $this->db->count_all_results();
        
        return $query;
    
    }

I believe this works since I also use it for another pagination. But then again.. I may be missing something.


Messages In This Thread
Pagination through search results - by El Forum - 05-08-2008, 02:47 AM
Pagination through search results - by El Forum - 05-08-2008, 02:59 AM
Pagination through search results - by El Forum - 05-08-2008, 03:07 AM
Pagination through search results - by El Forum - 05-08-2008, 03:17 AM
Pagination through search results - by El Forum - 05-08-2008, 03:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB