Welcome Guest, Not a member yet? Register   Sign In
Search result and pagination class
#21

[eluser]bluepicaso[/eluser]
but i have to other project running on localhost as well as on server with same code. I just copied the same code. How is that possible that searching works on those and not in my new project
#22

[eluser]bluepicaso[/eluser]
My code for previous project was this
Code:
function search()
    {
        $key = $this->input->post('key');
        $what = $this->input->post('what');
        $tags = $key;
        $tags=ltrim($tags);
        $tags=rtrim($tags);
        if(($tags == "") || ($tags == null))
        {
             $data['response'] ="Oopps, seems you did not enter the keywords";
             $data['response_image'] = 'error.png';
             $data['color']='red';
             $data['page'] = base_url();
             $data['alt'] = "";
             $this->load->view('ok', $data);
        }
        else
        {
             //echo $keyword;
             redirect("welcome/searching/$key/$what");    
        }
    }
    
    function searching($keyword, $what)
    {
        $tags = $keyword;
        $tags=ltrim($tags);
        $tags=rtrim($tags);
        $kt=split("_",$tags);//<------- Using the Split() working fine
        $q="";
      
      //----------------------------WHEN BOTH ARE ALL-----oNLY KEY WORD SEARCH IS NEEDED------------
        
        {
            $data['pageId'] = 2;
            while(list($key,$val)=each($kt))
              {
                        if($val<>" " and strlen($val) > 0)
                        {
                             $val=ltrim($val);
                             $val=rtrim($val);
                            $q .="details like '%$val%' or ";
                        }
              }
              $q=substr($q,0,(strLen($q)-3));
              //echo ($q);
              
              $this->load->library('pagination');
              $config['base_url'] = base_url() . "welcome/searching/$keyword/$what";
              
                    if($what == "jwls")
                    {
                        $config['total_rows'] = $this->db->count_all("normal where ".$q);    
                    }
                    elseif($what == "gems")
                    {
                        $config['total_rows'] = $this->db->count_all("gems where ".$q);    
                    }
              
              $config['per_page'] = '20';
              //$config['page_query_string'] = TRUE;
              $config['full_tag_open'] = '<p>';
              $config['full_tag_close'] = '</p>';
              $config['uri_segment'] = 5;
              $data['best'] = @$this->get->getBest();
              $this->pagination->initialize($config);
              
              
                    if($what == "jwls")
                    {
                        $data['gotSearchedJwl'] = @$this->get->getSearchedJwl($keyword, $config['per_page'],$this->uri->segment(5));
                        if($data['gotSearchedJwl'] == null)
                        {
                            $data['gotSearchedJwl'] ="none";
                        }
                    }
                    elseif($what == "gems")
                    {
                        $data['gotSearchedJwl'] = @$this->get->getSearchedGem($keyword, $config['per_page'],$this->uri->segment(5));
                        if($data['gotSearchedJwl'] == null)
                        {
                            $data['gotSearchedJwl'] ="none";
                        }
                    }
                    //print_r($data['gotSearchedJwl']);
                    if($what == "gems")
                    {
                        $data['mainContent'] = "searchedListGem";
                    }
                    else
                    {
                        $data['mainContent'] = "searchedListJwl";
                    }
                    $this->load->view('includes/template', $data);
        }
    }
#23

[eluser]bluepicaso[/eluser]
Code for the new project(for which th split is not workiing is )
Code:
function searchFrnds()
    {
        $keywords = $this->input->post('srchfrnds');
        $what = $this->input->post('what');
        
        $tags = $keywords;
        
        $tags=ltrim($tags);
        $tags=rtrim($tags);
        if(($tags == "") || ($tags == null))
        {
            $page = base_url()."welcome/friends";
        ?&gt;
        &lt;html&gt;
            &lt;head&gt;
                &lt;meta http-equiv="Refresh" content="5; url=&lt;?=$page?&gt;"&gt;
            &lt;/head&gt;
            &lt;body&gt;
                &lt;style&gt;
                    #rsp
                    {
                        border: #b55024 1px solid;
                        background-color: #edbca7;
                        font-size: 20px;
                        color: #5F4412;
                    }
            &lt;/style&gt;
            <div id='rsp'>
                OOps, No keywords submitted....
                <br>
                    <h6>
                        Please wait you will be redirected shortly
                    </h6>
            </div>
            &lt;/body&gt;
        &lt;/html&gt;
        &lt;?
        }
        else
        {
            
            //echo $keywords."hello";
            redirect("welcome/searchingFrnd/$tags/$what");    
        }
    }
    
    function searchingFrnd($tags, $what)
    {
        //echo $tags;
        //$tags = $keyword;
        //$tags=ltrim($tags);
        //$tags=rtrim($tags);
        $kt =split("_",$tags);//<---- split( not working here)
        $q="";
        
        //-----loading pagination class------
        
        $this->load->library('pagination');
        $config['base_url'] = base_url() . "welcome/searching/$keyword/$what";
        //-----getting pagination as -------
        if($what == "email")
        {
            while(list($key,$val)=each($kt))
             {
                       if($val<>" " and strlen($val) > 0)
                       {
                            $val=ltrim($val);
                            $val=rtrim($val);
                            $q .="email like '%$val%' or ";
                       }
             }
        }
        else
        {
            while(list($key,$val)=each($kt))
            {
                      if($val<>" " and strlen($val) > 0)
                      {
                           $val=ltrim($val);
                           $val=rtrim($val);
                              $q .="display_name like '%$val%' or ";
                      }
            }
        }
        $q=substr($q,0,(strLen($q)-3));
        $config['total_rows'] = $this->db->count_all("user where ".$q);
        $config['per_page'] = '20';
        $config['full_tag_open'] = '<p>';
        $config['full_tag_close'] = '</p>';
        $config['uri_segment'] = 5;
        $this->pagination->initialize($config);
        if($what == "email")
        {
            $data['gotFrnds'] = @$this->get->getSearchedFrndByEmail($keyword, $config['per_page'],$this->uri->segment(5));
        }
        else
        {
            $data['gotFrnds'] = @$this->get->getSearchedFrndByName($keyword, $config['per_page'],$this->uri->segment(5));
        }
        
        
        $data['content'] = "srchdfriends";
        $this->load->view('includes/user_template', $data);
        
    }

They both are on localhost, same Ci version, and using wamp server.

Please help guys.
#24

[eluser]umefarooq[/eluser]
both are on same machine or some other machine and also what's you PHP version and simple solution just change split to explode function both work same.
#25

[eluser]bluepicaso[/eluser]
both are on same machine

Thank you
Explode worked well though. But I'm still confused
#26

[eluser]umefarooq[/eluser]
koee naheen sardar gee hota banda confuse hoo jata ha




Theme © iAndrew 2016 - Forum software by © MyBB