Welcome Guest, Not a member yet? Register   Sign In
search feature & result with pagination links
#5

[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">&nbsp;</TD>
        </TR>
        <TR>
            <TD>Search Feeds:&nbsp;&lt;input type="text" name="feed" value="" /&gt; </TD>
        </TR>

        <TR>
            <TD>
            &lt;input type="hidden" name="search_view_form" value="1" /&gt;
            &lt;input type="submit" value="Submit" /&gt;
            </TD>
        </TR>
    </table>
&lt;/form&gt;


Search Controller is


Code:
&lt;?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);
    }

}

?&gt;





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.


Messages In This Thread
search feature & result with pagination links - by El Forum - 09-02-2008, 06:43 AM
search feature & result with pagination links - by El Forum - 09-02-2008, 06:11 PM
search feature & result with pagination links - by El Forum - 09-03-2008, 03:22 AM
search feature & result with pagination links - by El Forum - 09-03-2008, 10:30 AM
search feature & result with pagination links - by El Forum - 09-04-2008, 09:50 AM
search feature & result with pagination links - by El Forum - 09-04-2008, 11:05 AM
search feature & result with pagination links - by El Forum - 09-05-2008, 10:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB