Welcome Guest, Not a member yet? Register   Sign In
Pagination page not found
#1

[eluser]junaids[/eluser]
Hi.
I have a problem with my pagination implementation.
heres the model
Code:
<?
class Eventsmodel extends Model {
    function Eventsmodel(){
    parent::Model();}
      function getallEvents() {
    $this->db->select('*')->from('event')->order_by('Event_date', 'desc');
    $this->db->limit(5);
    $Q = $this->db->get();
    if ($Q->num_rows() > 0) {
        return $Q->result();
       } else {
         return FALSE;
    }
}

function getNumEvents()
{
    return $this->db->count_all('event');
}
and controller function
Code:
function home()
{
    $config['base_url'] = 'http://localhost/codeigniter/index.php/events/home';
    $config['total_rows']=$this->eventsmodel->getNumEvents();
    $config['per_page'] = '5';
    $this->pagination->initialize($config);

    $data['css'] = $this->css;
       $data['base'] = $this->base;
    $allevents = $this->eventsmodel->getallEvents();
    $data['events'] = $allevents;
    $data['links']=$this->pagination->create_links();
    $this->load->view('events/home', $data);
    }

my url is
http://localhost/codeigniter/index.php/events/home

when i click on next page link i get this error
Code:
404 Page Not Found
The page you requested was not found.
and the url of this page is
http://localhost/codeigniter/index.php/e...per_page=5
#2

[eluser]junaids[/eluser]
any body home!
#3

[eluser]Dam1an[/eluser]
[quote author="junaids" date="1245463997"]any body home![/quote]

Wow, somebody is rather impatient, and after just 45 minutes!
#4

[eluser]bretticus[/eluser]
I don't think your 404 issue has anything to do with your pagination code.
#5

[eluser]junaids[/eluser]
@Dam1an
I am used to getting fast replys, specially from you.
if theres no problem with my pagination code then what is the problem
#6

[eluser]Dam1an[/eluser]
a) You can't always expect a quick response, there are always quiet periods due to the time lol
b) I didn;t initially reply cause pagination isn't my forte (I very rarely use it)
c) It looks by the generated URL that it's trying to use a combination of query strings and segment based URLs, do you have query strings enabled in config?
#7

[eluser]n0xie[/eluser]
The clue is probably here
Code:
http://localhost/codeigniter/index.php/events/home&per_page=5

and here
Code:
$config['base_url'] = 'http://localhost/codeigniter/index.php/events/home';
Common Sherlock!
#8

[eluser]junaids[/eluser]
yes i have query string enabled
#9

[eluser]junaids[/eluser]
got it.

the problem was with this line.
Code:
$config['base_url'] = 'http://localhost/codeigniter/index.php/events/home/';

a backslash at the end was needed
#10

[eluser]n0xie[/eluser]
Good Job Sherlock! (sorry I got tired of pointing to the obvious :-P )




Theme © iAndrew 2016 - Forum software by © MyBB