paging problem Search form

#1
[eluser]xico[/eluser]
Code:
[quote]$data['siteTitle'] = 'My Test Project';
        $data['results'] = $this->usermodel->get_all();
        $data['totalRecords'] = $this->usermodel->countTotal();
        $data['pagingStr'] = $this->usermodel->paging($data['totalRecords']);
        if($data['totalRecords'] < 1) {
            $data['messageString'] = 'Sorry no records found!';
        } else {
            $data['messageString'] = '';
        }
        if (is_array($_GET) && (count($_GET) > 0))
        {
            $data['sn'] = floor((10 * $this->usermodel->page)+1);
        } else {
            $data['sn'] = 1;
        }
        $this->load->view('user_view',$data);

function get_all()
    {    
        if (is_array($_GET) && (count($_GET) > 0))
        {
            $this->page = $_GET['per_page'];

            foreach($_GET as $index => $value)
            {
                if($index != 'SortBy' && $index != 'OrderBy' && $index != 'Submit' && $index != 'c' && $index != 'per_page' && $value <> '')
                {
                    $this->db->where($index.' like "%'.$value.'%"');
                }
            }
        }
        
        //check query
        //$this->db->debug = true;
        
        $start = ($this->page * $this->limit);
        $this->db->orderby('Email','asc');
        $query = $this->db->get('users', $this->limit, $start);
        return $query->result();
    }

    function countTotal()
    {    
        if (is_array($_GET) && (count($_GET) > 0))
        {
            foreach($_GET as $index => $value)
            {
                if($index != 'SortBy' && $index != 'OrderBy' && $index != 'Submit' && $index != 'c' && $index != 'per_page' && $value <> '')
                {
                    $this->db->where($index.' like "%'.$value.'%"');
                }
            }
        }
        $query = $this->db->get('users');
        return $query->num_rows();
    }

    function paging($total = 0)
    {    
        $strURL = '';
        if (is_array($_GET) && (count($_GET) > 0))
        {
            foreach($_GET as $index => $value)
            {
                if($index <> 'per_page' && $index <> 'c' && $index <> 'm')
                {
                    $strURL .= '&'.$index.'='.$value;
                }
            }
        }

        $this->load->library('pagination');

        $config['base_url'] = $this->config->config['base_url'].'user/index/?c=user'.$strURL;
        $config['total_rows'] = ceil($total/$this->limit);
        $config['per_page'] = '1';
        $config['num_links'] = 5;

        $this->pagination->initialize($config);

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

    }
[/quote]

#2
[eluser]überfuzz[/eluser]
Nice post dude! Is there something else? Confusedmirk:

#3
[eluser]Thorpe Obazee[/eluser]
[quote author="überfuzz" date="1242649997"]Nice post dude! Is there something else? Confusedmirk:[/quote]

lol.

#4
[eluser]Dam1an[/eluser]
I somehow saw the 2 replies first, and was wondering wtf... then I saw the post lol
Glad to see I'm not the only one wondering

(also, whats with the quotes inside the code block?)

#5
[eluser]JulianM[/eluser]
Did you solve your problem?

Just was wondering.

#6
[eluser]gvillavizar[/eluser]
[quote author="JulianM" date="1242774218"]Did you solve your problem?

Just was wondering.[/quote]

Well, he didn't explained the problem in the first place.

#7
[eluser]JulianM[/eluser]
Yes, basically that is why I asked :p

[quote author="gvillavizar" date="1242778083"][quote author="JulianM" date="1242774218"]Did you solve your problem?

Just was wondering.[/quote]

Well, he didn't explained the problem in the first place.[/quote]

#8
[eluser]maxfuchs[/eluser]
I was wondering is there anyone could help him?

#9
[eluser]maxfuchs[/eluser]
anyone could help him?
poor him lol

#10
[eluser]dine[/eluser]
My problem is somewhat similar to post.

I am writing a custom query and using
$this->db->query($Sql);

now I need to do paging.

i am wondering what I need to write as limit in searching query. I means...for example
$Sql = "select * from abc limit startindex,lastindex"
Just ignore the error,syntax..
There is no restriction to use POST or GET Method.

Kindly let me know if you need to ask anything else more to reslove this prob.

thanks in advance


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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