Pagination config problem |
[eluser]LuckyFella73[/eluser]
I don't know if you are doing something wrong at all! Do you expect more results than you get? I mean if you get results then your code works basically. In case you expect more than the results you get you have to look at your query. If I where you I would echo Code: $this->db->last_query();
[eluser]ToXXXic[/eluser]
I think I found where the problem is, but I am not sure how to solve it: the Code: echo $this->db->last_query(); Code: SELECT * FROM (`company`) LIMIT 4 I am not sure why is it adding the LIMIT: here is the code I use to get the data Code: $query=$this->db->get('company',$perpage, $this->uri->segment(3)); the $perpage is passed from $config['per_page']. Thanks T
[eluser]SPeed_FANat1c[/eluser]
[quote author="ToXXXic" date="1289862691"]I think I found where the problem is, but I am not sure how to solve it: the Code: echo $this->db->last_query(); Code: SELECT * FROM (`company`) LIMIT 4 I am not sure why is it adding the LIMIT: here is the code I use to get the data Code: $query=$this->db->get('company',$perpage, $this->uri->segment(3)); the $perpage is passed from $config['per_page']. Thanks T[/quote] http://ellislab.com/codeigniter/user-gui...tml#select
[eluser]LuckyFella73[/eluser]
Maybe you can try it the following way. You can write it shorter and it's not tested but it should work: Code: # CONTROLLER:
[eluser]CI_Newb[/eluser]
Well I got it working using the above method of 1 query to get the total rows, then another for the pagination but I've come across another problem So I enter some search criteria into my form and the results do return properly along with the pagination as expected. Problem is when I go to another page within the pagination, its re querying the database with an empty form. I either need to get the values in the form to stick throughout the pagination pages or ..... I dunno actually.
[eluser]SPeed_FANat1c[/eluser]
I guess this is because of sentences like this: Code: $this->db->or_like('business',$this->input->post('search')); it takes data from $_POST array. And when you click on pagination link, there is no more data in $_POST (effect like the form is empty). You need to pass the data to query somehow different. You need to use $this->input-post only ionitially then save those input values or something so you could use them again when page is clicked.
[eluser]CI_Newb[/eluser]
[quote author="SPeed_FANat1c" date="1291039423"]I guess this is because of sentences like this: Code: $this->db->or_like('business',$this->input->post('search')); it takes data from $_POST array. And when you click on pagination link, there is no more data in $_POST (effect like the form is empty). You need to pass the data to query somehow different. You need to use $this->input-post only ionitially then save those input values or something so you could use them again when page is clicked.[/quote] Exactly. Thats why I thought of using a simple hidden form that grabs the values from the search. Just need to figure out a way to make the pagination links submit that hidden form. So far no luck
[eluser]LuckyFella73[/eluser]
I would recommend to do this by using session variables. Otherwise you would have to modify the pagination library to create one form for each pagination link. Sounds not like a clean solution .. There are some posts about how to solve this issue around this forums.
[eluser]SPeed_FANat1c[/eluser]
I can think of one solution with long urls: www.domain.com/results/parameter1/param2/paran3/pagination_offset so when you click submit then you pass input data to url and sentences like Code: $this->db->or_like('business',$this->input->post('search')); repalce with Code: $this->db->or_like('business',$this->uri->segment(x)); x - is the parameter from segment
[eluser]CI_Newb[/eluser]
[quote author="SPeed_FANat1c" date="1291043337"]I can think of one solution with long urls: www.domain.com/results/parameter1/param2/paran3/pagination_offset so when you click submit then you pass input data to url and sentences like Code: $this->db->or_like('business',$this->input->post('search')); repalce with Code: $this->db->or_like('business',$this->uri->segment(x)); x - is the parameter from segment[/quote] I would but this url would have like 20ish segments lol |
Welcome Guest, Not a member yet? Register Sign In |