[eluser]Joseph1982[/eluser]
Thank you for all of your responses.
Actually, I couldn't make any changes in the code after I read your suggestions.. So I would like to post the code here for making more clear:
The search form is:
Code:
<?=form_open('search')?>
<table>
<TR>
<TD align="center"> </TD>
</TR>
<TR>
<TD>Search Feeds: <input type="text" name="feed" value="" /> </TD>
</TR>
<TR>
<TD>
<input type="hidden" name="search_view_form" value="1" />
<input type="submit" value="Submit" />
</TD>
</TR>
</table>
</form>
Search Controller is
Code:
<?php
class Search extends Controller
{
function __construct()
{
parent::Controller();
$this->load->library(array('session', 'pagination', 'validation'));
$this->load->helper(array('form', 'url'));
$this->load->model('Search_model');
}
function index()
{
/**
* Feed Searching:
* Doesn't receive a keyword, then no Feed will be displayed.
* if receive a keyword, then it stored into the 'Session'.
* Use this Session value in next searching case, when the user click on the Pagination Links.
*/
$data['feeds'] = array();
$data['pagination_links']= '';
$search_view_form = $this->input->post('search_view_form');
$keyword = $this->input->post('feed');
if($search_view_form == 1 AND $keyword != "")
{
$this->session->set_userdata('search_keyword_feed', $keyword);
}
elseif($search_view_form == 1 AND $keyword == "")
{
$this->session->unset_userdata('search_keyword_feed');
}
if($this->session->userdata('search_keyword_feed'))
{
$keyword = $this->session->userdata('search_keyword_feed');
$config['base_url'] = site_url().'/search/index/';
// Calling the Model function for getting the total number of records.
$config['total_rows'] = $this->Search_model->search_num_rows($keyword);
// Number of Records displayed per page.
$config['per_page'] = '2';
$this->pagination->initialize($config);
// calling Model for getting the data.
$data['feeds'] = $this->Search_model->search_feed($keyword, $config['per_page'], $this->uri->segment(3,0));
$data['pagination_links']= $this->pagination->create_links();
}
// load the view
$this->load->view('search_results_view',$data);
}
}
?>
When I make a new search, then the form submits to a URL like:
http://mysite.com/index.php/search
When I click on the 2nd link from the pagination links, then the URL:
http://mysite.com/index.php/search/index/2
And when I click on the 1st link to go back to the first page of the search result, then the URL is:
http://mysite.com/index.php/search/index/
My requirement is to pass the 'Search Keyword' along with the URL itself. Presently I stored this search keyword inside the Session & I don't that its good practise!
I would like to hear from you all..
Thank You,
php developer.