• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination issue

#1
Hi have finally got pagination working (kind of) but cannot resolve two issues:
  • First link isn't actually a link its just a strong tag so you can never get back to the first page, even if you proceed clicking through the links it doesn't become active:

    <ul class="pagination">
    <strong>1</strong>
    <a href="http://codeigniter.local/jobs/12" data-ci-pagination-page="2">2</a>


  • The last link '>' always links to the second link as above, http://codeigniter.local/jobs/12
My controller class is as follows:
        $config["base_url"] = base_url() . "jobs";
        $config["total_rows"] = $this->jobs_model->record_count(); // returns the amount of rows
        $config["per_page"] = 12;
        $config["uri_segment"] = 2;
        $choice = $config["total_rows"] / $config["per_page"];
        $config["num_links"] = round($choice);

Maybe the tutorial I followed has led me up the garden path a bit, I did try and find one in the codeigniter documentation but could only find how to generate the pagination links but it didn't include how to integrate it into my queries so I ended up with pagination links but 500 records on one page.

If anyone could assist or point me to a decent tutorial it would be much appreciated.

I don't really know what else to post, the other functions are straight forward queries, I'm guessing the issue is in the config above. If I remove the last two then 'Last >' is appended to the end and has the correct link url.

I followed this tutorial:
https://www.sitepoint.com/pagination-with-codeigniter/
Reply

#2
@barrypoore,

Did you try to see if you could use the CI pagination feature first ( https://codeigniter.com/user_guide/libra...pagination )?
Reply

#3
The sitepoint tutorial is for CodeIgniter 2. There have probably been some changes for version 3 Undecided
php_rocs advice is reasonable Smile
Reply

#4
(07-12-2018, 05:47 PM)ciadmin Wrote: The sitepoint tutorial is for CodeIgniter 2. There have probably been some changes for version 3 Undecided
php_rocs advice is reasonable Smile

Yes I realise now that tutorial is dated, I found another one and have it all working now, it has one more method then I was hoping for but it seems to work, I'll check out that php_rocs, cheers.

Used this one now:
https://code.tutsplus.com/tutorials/pagi...-cms-29030
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
2 Guest(s)


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