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

[eluser]bluepicaso[/eluser]
Hello guys please help me. I nee to show a project to client within two days..One of which is gone. i need help in pagination.

Well i'm creating a keyword search with pagination.
The problem is i'm just enable to solve certain things please help me.

the result on my view
Quote:test
is Shown as this

An evening in Paris
Bagalore
Kashmir Valley

1 2 3 >


The problem is it is showing all the three results in a single page.
here is the code
View Form
Code:
<?php echo form_open('welcome/search');?>
Search <input type="text" name="tag"/> <input type="submit" value="Go!!"/>
<?php echo form_close();?>

My controller welcome/search

Code:
function search()
    {
        $q="";
        
        
        $keyword = $this->input->post("tag");
        //echo $keyword."  <hr>";
        
        
        redirect("welcome/searching/".$keyword);
    }
    function searching($keyword)
    {
        //echo $keyword;
        $tags = $keyword;
        $tags=ltrim($tags);
        $tags=rtrim($tags);
        $kt=split("_",$tags);
        $q="";
        while(list($key,$val)=each($kt))
        {
            if($val<>" " and strlen($val) > 0)
            {
                $val=ltrim($val);
                $val=rtrim($val);
                 $q .="DES like '%$val%' or ";
            }
        }
        $q=substr($q,0,(strLen($q)-3));
        //echo ($q);
        
        $this->load->library('pagination');
        $config['base_url'] = base_url() . "welcome/searching/" . $keyword;
        
        $config['total_rows'] = $this->db->count_all("package where ".$q);
        $config['per_page'] = '1';
        //$config['page_query_string'] = TRUE;
        $config['full_tag_open'] = '<p>';
        $config['full_tag_close'] = '</p>';
        $this->pagination->initialize($config);
        $this->load->model('home');
        
        $data['gotSearch'] = $this->home->getSearch($keyword, $config['per_page'],$this->uri->segment(4));
        echo $data['gotSearch'];
        //$data['gotPromo'] = $this->home->getPromo();
        //$data['gotAll'] = $this->home->getAll();
        $this->load->view('test', $data);
    }


My Model home/getSearch

Code:
function getSearch($q, $num, $offset)
    {
        //echo $q;
        
        $tags = $q;
    $tags=ltrim($tags);
        $tags=rtrim($tags);
    $kt=split("_",$tags);
        
    
        
    while(list($key,$val)=each($kt))
    {
            if($val<>" " and strlen($val) > 0)
            {
                $val=ltrim($val);
                $val=rtrim($val);
                $x[] = $val;
              
            }
    }
        //echo $x;
        $this->db->select('*');
        $this->db->from('package');
        $this->db->like('DES', "$x[0]");
        $tt = count($x);
        if ($tt>0)
        {
            for ($j=1;$j<$tt;$j++)
            {
                $this->db->or_like('DES', "$x[$j]");
               //echo $x[$j];
            }
        }

        $this->db->join('images', 'package.pak_id = images.pak_id', 'inner');
        $this->db->orderby('package.pac_name');
        
        $query = $this->db->get()->result_array();
        if($query == null)
        {
            //---no matching results-----
            echo "null";
            $data[] = "OOps No matching results";
        }
        foreach($query as $row)
        {
            $data[] = $row;
            //echo $row;
        }
            //echo $q;
        return $data;
    
    }

And the TEST view

Code:
&lt;?php
    foreach($gotSearch as $row)
    {
        ?&gt;
          
                &lt;?php echo $row['pac_name']."<br>"?&gt;
          
        &lt;?php
    }

?&gt;


Help me guys I dont wanna loose this project its my first on CODEIGNITER Confusedhut:
Please help Sad


Messages In This Thread
Search result and pagination class - by El Forum - 06-21-2009, 05:24 AM
Search result and pagination class - by El Forum - 06-21-2009, 05:42 AM
Search result and pagination class - by El Forum - 06-21-2009, 05:53 AM
Search result and pagination class - by El Forum - 06-21-2009, 05:55 AM
Search result and pagination class - by El Forum - 06-21-2009, 06:01 AM
Search result and pagination class - by El Forum - 06-21-2009, 06:10 AM
Search result and pagination class - by El Forum - 06-21-2009, 06:25 AM
Search result and pagination class - by El Forum - 06-21-2009, 07:21 AM
Search result and pagination class - by El Forum - 06-21-2009, 04:57 PM
Search result and pagination class - by El Forum - 06-22-2009, 09:15 AM
Search result and pagination class - by El Forum - 06-22-2009, 09:22 AM
Search result and pagination class - by El Forum - 06-22-2009, 11:42 AM
Search result and pagination class - by El Forum - 08-23-2009, 10:44 AM
Search result and pagination class - by El Forum - 08-23-2009, 01:59 PM
Search result and pagination class - by El Forum - 08-23-2009, 08:45 PM
Search result and pagination class - by El Forum - 04-06-2010, 08:20 PM
Search result and pagination class - by El Forum - 04-21-2010, 06:03 AM
Search result and pagination class - by El Forum - 04-21-2010, 07:45 AM
Search result and pagination class - by El Forum - 05-04-2010, 11:13 PM
Search result and pagination class - by El Forum - 05-05-2010, 02:29 AM
Search result and pagination class - by El Forum - 05-05-2010, 04:32 AM
Search result and pagination class - by El Forum - 05-05-2010, 04:53 AM
Search result and pagination class - by El Forum - 05-05-2010, 04:54 AM
Search result and pagination class - by El Forum - 05-05-2010, 05:15 AM
Search result and pagination class - by El Forum - 05-05-2010, 05:31 AM
Search result and pagination class - by El Forum - 05-05-2010, 05:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB