pagination with codeigniter not generating values












0















I have been trying to get this done, I want a pagination in my app. what i have now can only count the table rows. but when i click on the link to next batch of data, i receive a error 404.



Here is the code below.
This is my Controller



public function index($page='dboard', $offset=0){
$config['base_url'] = base_url() . 'manager/cplfc/';
$config['total_rows'] = $this->db->count_all('users','attendance');
$config['per_page'] = 1;
$config['uri_segment'] = 1;
$config['attributes'] = array('class' => 'pagination');

// Init Pagination
$this->pagination->initialize($config);


$data['users'] = $this->ManagerModel->get_users(FALSE, $config['per_page'], $offset);

if(!file_exists(APPPATH.'views/controls/manager/'.$page.'.php')){show_404();}
$data['title']=ucfirst($page);
$this->load->view('controls/manager/header');
$this->load->view('controls/manager/'.$page,$data);
$this->load->view('controls/manager/footer');
}


and this is the Model



public function get_users($id = FALSE, $limit = FALSE, $offset = FALSE){
if($limit){
$this->db->limit($limit, $offset);
}
if($id === FALSE){
$this ->db->order_by('id', 'desc');
$query = $this->db->get('users');
return $query->result_array();
}
}


And this is my view



<div class="pagination pagination-centered">
<ul><li><?php echo $this->pagination->create_links(); ?></li></ul>
</div>


What can i do to make it work? Thanks in advance










share|improve this question



























    0















    I have been trying to get this done, I want a pagination in my app. what i have now can only count the table rows. but when i click on the link to next batch of data, i receive a error 404.



    Here is the code below.
    This is my Controller



    public function index($page='dboard', $offset=0){
    $config['base_url'] = base_url() . 'manager/cplfc/';
    $config['total_rows'] = $this->db->count_all('users','attendance');
    $config['per_page'] = 1;
    $config['uri_segment'] = 1;
    $config['attributes'] = array('class' => 'pagination');

    // Init Pagination
    $this->pagination->initialize($config);


    $data['users'] = $this->ManagerModel->get_users(FALSE, $config['per_page'], $offset);

    if(!file_exists(APPPATH.'views/controls/manager/'.$page.'.php')){show_404();}
    $data['title']=ucfirst($page);
    $this->load->view('controls/manager/header');
    $this->load->view('controls/manager/'.$page,$data);
    $this->load->view('controls/manager/footer');
    }


    and this is the Model



    public function get_users($id = FALSE, $limit = FALSE, $offset = FALSE){
    if($limit){
    $this->db->limit($limit, $offset);
    }
    if($id === FALSE){
    $this ->db->order_by('id', 'desc');
    $query = $this->db->get('users');
    return $query->result_array();
    }
    }


    And this is my view



    <div class="pagination pagination-centered">
    <ul><li><?php echo $this->pagination->create_links(); ?></li></ul>
    </div>


    What can i do to make it work? Thanks in advance










    share|improve this question

























      0












      0








      0








      I have been trying to get this done, I want a pagination in my app. what i have now can only count the table rows. but when i click on the link to next batch of data, i receive a error 404.



      Here is the code below.
      This is my Controller



      public function index($page='dboard', $offset=0){
      $config['base_url'] = base_url() . 'manager/cplfc/';
      $config['total_rows'] = $this->db->count_all('users','attendance');
      $config['per_page'] = 1;
      $config['uri_segment'] = 1;
      $config['attributes'] = array('class' => 'pagination');

      // Init Pagination
      $this->pagination->initialize($config);


      $data['users'] = $this->ManagerModel->get_users(FALSE, $config['per_page'], $offset);

      if(!file_exists(APPPATH.'views/controls/manager/'.$page.'.php')){show_404();}
      $data['title']=ucfirst($page);
      $this->load->view('controls/manager/header');
      $this->load->view('controls/manager/'.$page,$data);
      $this->load->view('controls/manager/footer');
      }


      and this is the Model



      public function get_users($id = FALSE, $limit = FALSE, $offset = FALSE){
      if($limit){
      $this->db->limit($limit, $offset);
      }
      if($id === FALSE){
      $this ->db->order_by('id', 'desc');
      $query = $this->db->get('users');
      return $query->result_array();
      }
      }


      And this is my view



      <div class="pagination pagination-centered">
      <ul><li><?php echo $this->pagination->create_links(); ?></li></ul>
      </div>


      What can i do to make it work? Thanks in advance










      share|improve this question














      I have been trying to get this done, I want a pagination in my app. what i have now can only count the table rows. but when i click on the link to next batch of data, i receive a error 404.



      Here is the code below.
      This is my Controller



      public function index($page='dboard', $offset=0){
      $config['base_url'] = base_url() . 'manager/cplfc/';
      $config['total_rows'] = $this->db->count_all('users','attendance');
      $config['per_page'] = 1;
      $config['uri_segment'] = 1;
      $config['attributes'] = array('class' => 'pagination');

      // Init Pagination
      $this->pagination->initialize($config);


      $data['users'] = $this->ManagerModel->get_users(FALSE, $config['per_page'], $offset);

      if(!file_exists(APPPATH.'views/controls/manager/'.$page.'.php')){show_404();}
      $data['title']=ucfirst($page);
      $this->load->view('controls/manager/header');
      $this->load->view('controls/manager/'.$page,$data);
      $this->load->view('controls/manager/footer');
      }


      and this is the Model



      public function get_users($id = FALSE, $limit = FALSE, $offset = FALSE){
      if($limit){
      $this->db->limit($limit, $offset);
      }
      if($id === FALSE){
      $this ->db->order_by('id', 'desc');
      $query = $this->db->get('users');
      return $query->result_array();
      }
      }


      And this is my view



      <div class="pagination pagination-centered">
      <ul><li><?php echo $this->pagination->create_links(); ?></li></ul>
      </div>


      What can i do to make it work? Thanks in advance







      php codeigniter pagination






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 24 '18 at 14:10









      God's gloryGod's glory

      44




      44
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it and it should be normally $config['uri_segment'] = 3;






          share|improve this answer
























          • thanks for your reply. But its still showing 404 not found.

            – God's glory
            Nov 25 '18 at 19:46











          • Show me the url!

            – Sherif Salah
            Nov 25 '18 at 20:00











          • thanks alot. it was my url that wasn't correct. I still have one more question. How can i sort data without having to refresh the page

            – God's glory
            Nov 25 '18 at 20:24











          • in my code, i have a select object. I want it that in an "OnChange" even, the table values should change respectively

            – God's glory
            Nov 25 '18 at 20:26











          • Do you mean you wanna make ajax pagination with sort option? .. easy on click on col header send a request with limit and offset but toggle order of it .. you can send it via form data or change pagination type to accept uri string and pass it as a get request .. i know its easier said than done but i hope you got the idea .. or if you prefer use datatables

            – Sherif Salah
            Nov 25 '18 at 20:30











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53459010%2fpagination-with-codeigniter-not-generating-values%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it and it should be normally $config['uri_segment'] = 3;






          share|improve this answer
























          • thanks for your reply. But its still showing 404 not found.

            – God's glory
            Nov 25 '18 at 19:46











          • Show me the url!

            – Sherif Salah
            Nov 25 '18 at 20:00











          • thanks alot. it was my url that wasn't correct. I still have one more question. How can i sort data without having to refresh the page

            – God's glory
            Nov 25 '18 at 20:24











          • in my code, i have a select object. I want it that in an "OnChange" even, the table values should change respectively

            – God's glory
            Nov 25 '18 at 20:26











          • Do you mean you wanna make ajax pagination with sort option? .. easy on click on col header send a request with limit and offset but toggle order of it .. you can send it via form data or change pagination type to accept uri string and pass it as a get request .. i know its easier said than done but i hope you got the idea .. or if you prefer use datatables

            – Sherif Salah
            Nov 25 '18 at 20:30
















          0














          The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it and it should be normally $config['uri_segment'] = 3;






          share|improve this answer
























          • thanks for your reply. But its still showing 404 not found.

            – God's glory
            Nov 25 '18 at 19:46











          • Show me the url!

            – Sherif Salah
            Nov 25 '18 at 20:00











          • thanks alot. it was my url that wasn't correct. I still have one more question. How can i sort data without having to refresh the page

            – God's glory
            Nov 25 '18 at 20:24











          • in my code, i have a select object. I want it that in an "OnChange" even, the table values should change respectively

            – God's glory
            Nov 25 '18 at 20:26











          • Do you mean you wanna make ajax pagination with sort option? .. easy on click on col header send a request with limit and offset but toggle order of it .. you can send it via form data or change pagination type to accept uri string and pass it as a get request .. i know its easier said than done but i hope you got the idea .. or if you prefer use datatables

            – Sherif Salah
            Nov 25 '18 at 20:30














          0












          0








          0







          The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it and it should be normally $config['uri_segment'] = 3;






          share|improve this answer













          The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it and it should be normally $config['uri_segment'] = 3;







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 15:49









          Sherif SalahSherif Salah

          1,0941516




          1,0941516













          • thanks for your reply. But its still showing 404 not found.

            – God's glory
            Nov 25 '18 at 19:46











          • Show me the url!

            – Sherif Salah
            Nov 25 '18 at 20:00











          • thanks alot. it was my url that wasn't correct. I still have one more question. How can i sort data without having to refresh the page

            – God's glory
            Nov 25 '18 at 20:24











          • in my code, i have a select object. I want it that in an "OnChange" even, the table values should change respectively

            – God's glory
            Nov 25 '18 at 20:26











          • Do you mean you wanna make ajax pagination with sort option? .. easy on click on col header send a request with limit and offset but toggle order of it .. you can send it via form data or change pagination type to accept uri string and pass it as a get request .. i know its easier said than done but i hope you got the idea .. or if you prefer use datatables

            – Sherif Salah
            Nov 25 '18 at 20:30



















          • thanks for your reply. But its still showing 404 not found.

            – God's glory
            Nov 25 '18 at 19:46











          • Show me the url!

            – Sherif Salah
            Nov 25 '18 at 20:00











          • thanks alot. it was my url that wasn't correct. I still have one more question. How can i sort data without having to refresh the page

            – God's glory
            Nov 25 '18 at 20:24











          • in my code, i have a select object. I want it that in an "OnChange" even, the table values should change respectively

            – God's glory
            Nov 25 '18 at 20:26











          • Do you mean you wanna make ajax pagination with sort option? .. easy on click on col header send a request with limit and offset but toggle order of it .. you can send it via form data or change pagination type to accept uri string and pass it as a get request .. i know its easier said than done but i hope you got the idea .. or if you prefer use datatables

            – Sherif Salah
            Nov 25 '18 at 20:30

















          thanks for your reply. But its still showing 404 not found.

          – God's glory
          Nov 25 '18 at 19:46





          thanks for your reply. But its still showing 404 not found.

          – God's glory
          Nov 25 '18 at 19:46













          Show me the url!

          – Sherif Salah
          Nov 25 '18 at 20:00





          Show me the url!

          – Sherif Salah
          Nov 25 '18 at 20:00













          thanks alot. it was my url that wasn't correct. I still have one more question. How can i sort data without having to refresh the page

          – God's glory
          Nov 25 '18 at 20:24





          thanks alot. it was my url that wasn't correct. I still have one more question. How can i sort data without having to refresh the page

          – God's glory
          Nov 25 '18 at 20:24













          in my code, i have a select object. I want it that in an "OnChange" even, the table values should change respectively

          – God's glory
          Nov 25 '18 at 20:26





          in my code, i have a select object. I want it that in an "OnChange" even, the table values should change respectively

          – God's glory
          Nov 25 '18 at 20:26













          Do you mean you wanna make ajax pagination with sort option? .. easy on click on col header send a request with limit and offset but toggle order of it .. you can send it via form data or change pagination type to accept uri string and pass it as a get request .. i know its easier said than done but i hope you got the idea .. or if you prefer use datatables

          – Sherif Salah
          Nov 25 '18 at 20:30





          Do you mean you wanna make ajax pagination with sort option? .. easy on click on col header send a request with limit and offset but toggle order of it .. you can send it via form data or change pagination type to accept uri string and pass it as a get request .. i know its easier said than done but i hope you got the idea .. or if you prefer use datatables

          – Sherif Salah
          Nov 25 '18 at 20:30




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53459010%2fpagination-with-codeigniter-not-generating-values%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Create new schema in PostgreSQL using DBeaver

          Deepest pit of an array with Javascript: test on Codility

          Costa Masnaga