Welcome Guest, Not a member yet? Register   Sign In
Messing with pagination all day and I'm almost there.

This is probably very ugly but it seems to be working well thus far. Still have a few things to add.

Its doing pagination, sorting (keeping track of sort during page changes via cookie).

Any thoughts?

// Here we go with pagination

        $data[user_count] =  $this->db->count_all('users');

        if(get_cookie('user_sort')) {
            $sort = get_cookie('user_sort');

        if($this->uri->segment(4)) {
          $sort = $this->uri->segment(4);
          setcookie("user_sort", $sort);

        if(!$sort) {             $sort = "last_name";         }

        if($this->uri->segment(3))    {  $start = $this->uri->segment(3) ;  }
        if(!$start)                   {  $start = 0;  }


        $config['base_url'] = site_url() . "/users/page/";
        $config['total_rows'] = $data[user_count];
        $config['per_page'] = '5';
        $config['uri_segment'] = 3;
        $config['num_links'] = 5;

        $data['query'] = $this->db->query("SELECT * FROM users ORDER BY $sort ASC LIMIT $start,$config[per_page]");     // query time

        $data[pages] =  $this->pagination->create_links();

        $data[sys_message] = $this->session->flashdata('sys_message');  // set system message to display


almost there - goda throw a search field into the mix. Like to get some feed back if i'm going about things correctly in the long run.

Ah, thats a lot more clever than mine was... mostly because I wrote my own pagination system...

Its a lot more code now.

I have put in search, sorting, keeps you on the same page while sorting, drop down select option for an ENUM mysql table field to only show & search certain records (active/inactive/approve/canceled).

I think I almost done!

Theme © iAndrew 2016 - Forum software by © MyBB