pagination didn't work

#1
[eluser]marjune[/eluser]
my controller
Code:
function index(){
    $this->load->helper('form');
    $this->load->helper('url');
    $this->load->library('pagination');
    $config['base_url'] = base_url().'furoms/';
    $config['per_page'] = '5';
    $config['uri_segment'] = 3;
    $config['total_rows'] = $this->db->count_all('forum_topic'); // 9 records result
    $config['open_tag'] = '<p>';
    $config['close_tag'] = '</p>';
    $this->pagination->initialize($config);
    $furomcontent['data'] = $this->furom->furomcontent($config['per_page'], $config['uri_segment']);
    $this->load->vars($furomcontent);
    $this->load->view('viewfurom');
            
}

//my view

echo $this->pagination->create_links();

then when i click the second page the url is http://mysite.com/ci/index.php/furoms/&per_page=5 then

404 Page Not Found

The page you requested was not found.

#2
[eluser]1mr3yn[/eluser]
Code:
function furoms($offset=''){
    $this->load->helper('form');
    $this->load->helper('url');
    $this->load->library('pagination');
    $config['base_url'] = base_url().'furoms/';
    $limit  = $config['per_page'] = '5';
    $offset = $config['uri_segment'] = 3;
    $config['total_rows'] = $this->db->count_all('forum_topic'); // 9 records result
    $config['open_tag'] = '<p>';
    $config['close_tag'] = '</p>';
    $this->pagination->initialize($config);
    $furomcontent['data'] = $this->furom->furomcontent($limit,$offset);
    $this->load->vars($furomcontent);
    $this->load->view('viewfurom');
}

//my view

echo $this->pagination->create_links();

#3
[eluser]khagendra[/eluser]
According to ur $config['base_url'],
Code:
$config['base_url'] = base_url().'furoms/';

The uri_segment should be 2, like
Code:
$config['base_url'] = base_url().'furoms/';
$config['uri_segment'] = 3;

once try this, it should work.

#4
[eluser]marjune[/eluser]
well my problem is the pagination, since the total rows is 9 then the per page is 5 the pagination look like this
{

display 5 records here

}
1 2 >

when i click the 2nd page which the four remaining records will display the URL look like this http://mysite.com/ci/index.php/furoms/&per_page=5

then it will display 404 Page Not Found

The page you requested was not found.

#5
[eluser]khagendra[/eluser]
Why u are not using the .htaccess file to avoid index.php in the uri string.

To know how use it, please go through this link
http://ellislab.com/forums/viewthread/133024/#656543

After using .htaccess file u can write ur uri string will be like this.
Code:
http://mysite.com/ci/furoms/5

if u r using the .htaccess file. the uri_string will be 3.

Note: if u dont want to use .htaccess file now, then use uri string 4.

Code:
$config['uri_segment'] = 4;

#6
[eluser]1mr3yn[/eluser]
Quote:
Why u are not using the .htaccess file to avoid index.php in the uri string.
.htaccess doesn't make any sense in his problem.

Try this one..

Code:
function forum($offset='') {
          
    $limit = 5;
    $total = $this->db->count_all_results('table');        
    $data['sql'] = $this->model->function($limit, $offset);    
        
    $base_url = site_url('Urcontroller/forum');
    $config['base_url'] = $base_url;
        $config['total_rows'] = $total;
        $config['per_page'] = $limit;
    
    $this->pagination->initialize($config);
    $this->load->view('view_file',$data);

}

Have you tried to read the URI Routing in user guide page?

#7
[eluser]marjune[/eluser]
well, my url now look like this http://mysite.com/ci/index.php/furoms/5 after some changes in the pagination
but still 404 Page Not Found

The page you requested was not found.

#8
[eluser]saidai jagan[/eluser]
$config['base_url'] = base_url().'furoms/'; to $config['base_url'] = base_url().'furoms/index/';
Wink

#9
[eluser]Zeeshan Rasool[/eluser]
[quote author="saidai jagan" date="1257532063"]$config['base_url'] = base_url().'furoms/'; to $config['base_url'] = base_url().'furoms/index/';
Wink[/quote]

Yeah, it can work i think. because we should keep in mind the url segment position

#10
[eluser]marjune[/eluser]
$config[‘base_url’] = base_url().‘furoms/index/’;

no error but nothings change


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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