views:

43

answers:

0

Okay, I am pretty new in CI and I am stuck on pagination. I am performing this pagination on a record set that is result of a query. Now everything seems to be working fine. But there's some problem probably with the link. I am displaying 10 results per page. Now if the results are less than 10 then it's fine. Or If I pull up the entire records in the table it works fine. But in case the result is more than 10 rows, then the first 10 is perfectly displayed, and when I click on the pagination link to get to the next page the next page displays the rest of the results from the query as well as, other records in the table. ??? I am confused.. Any help??

Here's the model code I am using ....

function getTeesLike($field,$param)
{
    $this->db->like($field,$param);
    $this->db->limit(10, $this->uri->segment(3));
    $query=$this->db->get('shirt');
    if($query->num_rows()>0){
        return $query->result_array();
    }
}

function getNumTeesfromQ($field,$param)
{
    $this->db->like($field,$param);
    $query=$this->db->get('shirt');
    return $query->num_rows();
}

And here's the controller code ....

$KW=$this->input->post('searchstr');
$this->load->library('pagination');
$config['base_url']='http://localhost/cit/index.php/tees/show/';
$config['total_rows']=$this->T->getNumTeesfromQ('Title',$KW);
$config['per_page']='10';
$this->pagination->initialize($config);
$data['tees']=$this->T->getTeesLike('Title',$KW);
$data['title']='Displaying Tees data';
$data['header']='Tees List';
$data['links']=$this->pagination->create_links();
$this->load->view('tee_res', $data);

What am I doing wrong here ???? Pls help ...

I guess the problem is with the $KW=$this->input->post('searchstr'); .. Because if I hard code a value for $KW it works fine. May be I should use POST differently ..but how do I pass the value from the form without POSTING it , its CI so not GET ... ??????