Welcome Guest, Not a member yet? Register   Sign In
Problem with pagination
#7

[eluser]Docmo[/eluser]
Yes!

Ok i'm gonna start from the beginning, the view, here is the code for the seach engine in the view :

Code:
<?php echo form_open('job/resultats');?>
   <input type="text" name="contenu" value="Rechercher une offre dans" size="30" >
   <select  name="categorie">
      <option value="" selected>Toutes les offres</option>
      <option value="Babysitting">Babysitting</option>
      <option value="Éducation">Éducation</option>
      <option value="Agriculture">Agriculture</option>
    </select>
    &lt;input type="submit" value="Recherche" /&gt;
    &lt;/form&gt;

So, if we type the word "test", we obtain the link http://www.job24.ca/job/resultats with the 3 firts results containing the word "test".

The code in the controller :

Code:
$tmp=3;
            if($this->uri->segment(4)){ //executed if the user click on "2" or more
                $query = $this->Model_job->getResult($_POST['categorie'], $_POST['contenu'], $this->uri->segment(4) ,$tmp);
                $query2 = $this->Model_job->getResult($_POST['categorie'], $_POST['contenu'], 0 ,0);
            }
            else//executed when clicking on "1"
            {
                $query = $this->Model_job->getResult($_POST['categorie'], $_POST['contenu'], '0' , $tmp);//only 3 results
                $query2 = $this->Model_job->getResult($_POST['categorie'], $_POST['contenu'], 0 , 0);//to obtain the total number of results
            }


            $search = explode(' ', $_POST['contenu']);//generating a link containing the key words
            $req = 'http://www.job24.ca/job/resultats/';
            $req = $req.$search[0];
            for($i=1;$i<count($search);$i++)
            {
                $req=$req."-".$search[$i];
            }
                        //configuring the pagination
            $config['base_url'] = $req;
            $config['total_rows'] = $this->countRes($query2);
            $config['per_page'] = $tmp;
            
            $this->pagination->initialize($config);
            $data['links']=$this->pagination->create_links();
            $data['res'] = $query;
            $this->load->view('resultats',$data);

So the problem is, when we click on 2, the browser reload the page, but when it happens, the browser forgets our query in the search engine, and executes another part in the code but he hasn't anymore the $_POST['categorie'] and $_POST['contenu'], so we obtain a SQL error because we lost a variable!

Hope you better understand the problem!

Thx!


...


Messages In This Thread
Problem with pagination - by El Forum - 06-25-2009, 02:22 PM
Problem with pagination - by El Forum - 06-25-2009, 02:29 PM
Problem with pagination - by El Forum - 06-25-2009, 03:03 PM
Problem with pagination - by El Forum - 06-25-2009, 04:16 PM
Problem with pagination - by El Forum - 06-25-2009, 04:25 PM
Problem with pagination - by El Forum - 06-26-2009, 04:21 AM
Problem with pagination - by El Forum - 06-26-2009, 02:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB