Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Search
#1

[eluser]georgerobbo[/eluser]
Hello, I'm building a basic search form which will query all fields of the database and return any matching results. I'm struggling with writing the code. This is what I currently have.

Code:
<?php

class Search extends Model {

    function Search()
    {
        parent::Model();
    }
    
    function get_result()
    {
        /* Retrieve from Form */
        $keyword = $_POST['keyword'];
        trim ($keyword);
        
        /* Trim (Remove White Space) */
        
        if (!get_magic_quotes_gpc())
        {
        $keyword = addslashes($keyword);
        }
        
        /* Query SQL */
        $this->db->select('*');
        $this->db->where('tablerow like '%".$keyword."%'');
        
        $query = $this->db->get('user');
        return $query;
    }
    
}
#2

[eluser]InsiteFX[/eluser]
PHP keyword Search

Enjoy
InsiteFX
#3

[eluser]mikegniewosz[/eluser]
Try this.

Code:
$this->db->like('tablerow', $keyword);
$query = $this->db->get('user');
return $query->result();




Theme © iAndrew 2016 - Forum software by © MyBB