Welcome Guest, Not a member yet? Register   Sign In
pagination not work
#1

[eluser]dinda[/eluser]
I am a beginner and i currently having problem with paging and the result.
and then the searching is works, but paging is not.

Help me please...

This is my code:

Code:
/* controller : */

class Test extends Controller {
    
    function test()
    {
        parent::Controller();    
        
        $this->load->helper('url');
        $this->load->helper('form');
        $this->load->model("test_model");
        $this->load->library('pagination');
        $this->load->database();
    }
    
    function index()
    {
        
        /* Parameter Search Field */
        $data['keyword'] = false ;
        $this->test_model->keywordsearch = false;
        
        /*load pagination class */
        $config['uri_segment'] = 4;
        $config['base_url'] = base_url().'index.php/test/index/';
        $config['full_tag_open'] = '<p>';
        $config['full_tag_close'] = '</p>';
        $config['per_page'] = '2';
        $config['total_rows'] = $this->db->count_all('ms_user');

        $this->pagination->initialize($config);
        
        /* Model Process */
        $data['queryuser'] = $this->test_model->search_test_data($config['per_page'],$this->uri->segment(3));
        
        
        /* View Passing */
        $this->load->library('table');    
        $this->table->set_heading('ID', 'Name');

        /* Show Output */
         $this->load->view("test_list_v", $data);    
        
    }
    
    function search_test()
    {
        
        /* Parameter Search Field */
        $data['keyword'] = $this->input->post('keyword');
        $this->test_model->keywordsearch = $this->input->post('keyword');
        
        /*load pagination class */
        $config['uri_segment'] = 4;
        $config['base_url'] = base_url().'index.php/test/index/'. $this->uri->segment(3);
        $config['full_tag_open'] = '<p>';
        $config['full_tag_close'] = '</p>';
        $config['per_page'] = '2';
        $config['total_rows'] =  $this->db->count_all('ms_user');
        
        $this->pagination->initialize($config);
        
        $offset = (int)$this->uri->segment(4);
        
        /* Model Process */
        $data['queryuser'] = $this->test_model->search_test_data($config['per_page'], $offset);
        

         /* View Passing */
         $this->load->library('table');
         $this->table->set_heading('ID', 'Name');
        
        /* Show Output */
         $this->load->view("test_list_v", $data);    
        
    }
    
    
}

Code:
/* model : */
function search_test_data($num, $offset = false )
{
$this->db->select('userid,username');
$this->db->from('ms_user');      

if ($this->keywordsearch) {
$this->db->like("username", $this->keywordsearch);
}

if ($offset)
{
$this->db->limit($num,$offset);        
}
else
{
$this->db->limit($num);        
}
        
$this->db->order_by('userid');
        
$query = $this->db->get();

return $query;
}

Code:
&lt;!-- View --&gt;
&lt;form name="user_find" id="user_find" method="POST" action="&lt;?=site_url('test/search_test')?&gt;"&gt;
        Cari Nama User :
            &lt;input type='text' name='keyword' id='keyword' value='&lt;?= $keyword; ?&gt;'  /&gt;
            &lt;input type="submit" name="Submit" value="Find"&gt;
&lt;/form&gt;
    
echo $this->table->generate();
echo $this->pagination->create_links();


Messages In This Thread
pagination not work - by El Forum - 06-30-2008, 11:20 PM
pagination not work - by El Forum - 07-01-2008, 12:22 AM
pagination not work - by El Forum - 07-01-2008, 12:29 AM
pagination not work - by El Forum - 07-04-2008, 02:28 AM
pagination not work - by El Forum - 07-04-2008, 03:06 AM
pagination not work - by El Forum - 07-04-2008, 04:01 AM
pagination not work - by El Forum - 07-04-2008, 04:02 AM
pagination not work - by El Forum - 07-04-2008, 05:23 AM
pagination not work - by El Forum - 07-04-2008, 11:43 AM
pagination not work - by El Forum - 08-23-2009, 12:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB