• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search with Pagignation

#1
Hi,

I am trying to make a search with pagignation . And i already make it . But pagignation its not working properly. For pagignation i follow this tutorial :https://ellislab.com/codeigniter/user-guide/libraries/pagination.html

If i in second page (with pagignation ) and then try to back in 1st page (by clicking pagignation number) . Then its shows me all result again . Also url is showing /10 . I think url need to show this with my search query . So, in future anyone can use this url.

I am new with codeigniter. And search lot in google . Please any help will highly appreciate.

Best Regards
Reply

#2
I've had the exact same problem! My implementation was that search terms are passed through the URL using GET parameters, and using $config['suffix'] I could pass these values through pagination. For the first link, you will need to use $config['first_url'] to pass the variables through as the first link is not affected by the suffix config.

See http://stackoverflow.com/questions/53846...parameters for more information.
Reply

#3
Thanka advoor for quick response.. I will check this now..
Reply

#4
Hello , advoor

Sorry ,, Still its not works .. In my case , i have always search_result/10 . Its never takes suffeix..
See my controller :


public function search_result() {

$config['per_page'] = 1;

$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;

$keyword = $this->input->post('search');

// $num_rows = count($this->productos_model->get_search($config["per_page"], $page, $keyword));

$config['base_url'] = base_url() . 'search/search_result/';

$config['total_rows'] = $this->productos_model->get_search_num_rows($keyword);

$config["uri_segment"] = 3;

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

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

$data["results"] = $this->productos_model->get_search($config["per_page"], $page, $keyword);




$this->load->view('template/template', $data);
}
Thanks for your time again..
Reply

#5
You must use the configuration options before you initialise the pagination: e.g. my config is

PHP Code:
$config['suffix'] = '/filter?start_date='.$search_start_date.'&end_date='.$search_end_date;
$config['first_url'] = '/filter?start_date='.$search_start_date.'&end_date='.$search_end_date;

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

Hope that helps.
Reply

#6
(01-30-2015, 08:10 AM)advoor Wrote: You must use the configuration options before you initialise the pagination: e.g. my config is

PHP Code:
$config['suffix'] = '/filter?start_date='.$search_start_date.'&end_date='.$search_end_date;
$config['first_url'] = '/filter?start_date='.$search_start_date.'&end_date='.$search_end_date

I have some config set up. As you saw my code . But how did you set up this two config option ['suffix'] and ['first_url']
in my url never get filter?start_date , or any thing . and ,its always shows me search_result/10 then search_result/20
I know something i did wrong.. But can't figure out.
thanks
Reply

#7
(01-30-2015, 08:22 AM)code_help Wrote: I have some config set up. As you saw my code . But how did you set up this two config option ['suffix'] and ['first_url']
in my url never get filter?start_date , or any thing . and ,its always shows me search_result/10  then search_result/20
I know something i did wrong.. But can't figure out.
thanks

Did you put the config options just after
PHP Code:
$config["uri_segment"] = 3
?

The dates are just values passed through the URL :

PHP Code:
$search_start_date $this->input->get('start_date');
$search_end_date $this->input->get('end_date'); 
Reply

#8
Yes. I have this ($config["uri_segment"] = 3; )set in config option . and then i add your two new code ,, But nothing change.

I follow https://www.youtube.com/watch?x-yt-ts=14...14404#t=40 this tutorial . And now its working fine . But they did with database . So, all query is saved in database. Its fine but for large side , i think session is good idea.

But still i don't get codeigniter session class and other stuff.

Thanks again for your time.. If you know, any tutorial regarding this, please let me know .

Have a nice day.
Reply

#9
Hi there

I use DataTables for all my table usages in CodeIgniter, basically I dump my sql result to tables by using table helper class to
VIEW then in view I simply make that table as instance of DaTaTables then you will see it all set. Table is auto paginated with
global smart search for all column fields.

For example, i have a query for all customers then lets say $customer_table as passing param to view and make sure you set ID in table
tag , assume it is #customer_table.

This is the magic on VIEW to turn it to DataTables

$('#customer_table').DataTable();

That is it! ...If you want more customized layout on your table then read this

https://datatables.net/

Hope this help
Reply

#10
Thanks Dbui for sharing this link.
Just have two question before using this awesome plugin, :
My search result is not table formatted so then is it worked? And my result will show in another page after submitted submit button.
And i have 3 join sql for search result.

Thanks again.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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