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

[eluser]TheFuzzy0ne[/eluser]
Yes, but only the actual query text, not the results. The hash itself is actually a has of the query, without the limit and offset I believe. For this forum, the search hashes seem to be removed after a certain period of time.
#12

[eluser]djalilk[/eluser]
[quote author="TheFuzzy0ne" date="1245608513"]You can use my URI-safe base_64 encoding helper. http://ellislab.com/forums/viewthread/107741/. It obfuscates the data somewhat, but it works. I also created an alternate URI syntax library which may also help. http://ellislab.com/forums/viewthread/10...10/#551378[/quote]

Thank you very much! It works fine Smile This is the best solution I've found for this problem Smile
#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
#14

[eluser]umefarooq[/eluser]
Hi put in you config

Code:
$config['uri_segment'] = 3;
or
$config['uri_segment'] = 4;

The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it.

check user guide also
http://ellislab.com/codeigniter/user-gui...ation.html
#15

[eluser]bluepicaso[/eluser]
OK no need, it worked... i forgot tu use
Code:
$this->db->limit($num, $offset);

how follish can i be %-P
#16

[eluser]ronald_allan_rivera[/eluser]
[quote author="bluepicaso" date="1251099907"]OK no need, it worked... i forgot tu use
Code:
$this->db->limit($num, $offset);

how follish can i be %-P[/quote]

It says "Array" on the top, how can I remove it? Thanks
#17

[eluser]Thug_Angel[/eluser]
[quote author="ronald_allan_rivera" date="1270624839"]
It says "Array" on the top, how can I remove it? Thanks[/quote]

remove or comment
Code:
echo $data['gotSearch'];
from controller
#18

[eluser]JanDoToDo[/eluser]
Hey guys.

Just thought I'd throw this out there - I do something very simple.

I just get the values which are used to search, and then write a form which is submitted when you change links.

I extended the pagination class to have another function "create_links_alt" and further i write a form when it gets the paginated data.

Code:
$form = form_open('search/index/');
        
    $form .= form_hidden('gender', $gender);
    $form .= form_hidden('photo', $photo);
    $form .= form_hidden('region', $region);
    if ($alt_search) $form .= form_hidden('alt_search', 'TRUE');
    $form .= form_close();

    $search['links'] = $this -> pagination -> create_links_alt();
}

So the form target would be the controller/method and the hidden fields would be the vars you want passed, e.g. from the uri variables or posted variables from a previous form.

Then, I just use my pagination library extension which changes the links to submit the form instead of just go to the next page!

If you want to get the pagination extension let me know
#19

[eluser]bluepicaso[/eluser]
I have a problem again. after so many project using the same function for keyword search. Now Suddenly i got this error

Previous code is here

Quote:A PHP Error was encountered

Severity: 8192

Message: Function split() is deprecated

Filename: controllers/welcome.php

Line Number: 368


Please help me someone. Please please.
#20

[eluser]umefarooq[/eluser]
as you can see the message Function split() is deprecated, if you are using PHP version 5.3.0, function split will not support you can use alternative function like explode to solve your problem it also work same as split

PHP link for split
http://www.php.net/manual/en/function.split.php

PHP link for explode
http://www.php.net/manual/en/function.explode.php

hope this will work for you




Theme © iAndrew 2016 - Forum software by © MyBB