[eluser]TheFuzzy0ne[/eluser]
If you want to use LIKE, your value should contain at least one wildcard (%). However, I don't think you should be using like here. If you want to find peple call "Paul", that who it should find. If you use like, you'll get results for Pauly, Paulie, Paula and so on. Is that what you want?
Also, your going to have problems if you hardcode the destination. The destination should be dynamic, and in a model. Although it may be more confusing for you at first, it gives you an API that you can re-use, and you won't have to keep rewriting the same code.
Code:
$destination = 'Spain';
$this->db->select('name, location,destination1, destination2, destination3, id');
$this->db->from('holidays');
if (isset($query_array['stayed']))
{
$this->db->where('(`destination1`="Spain" OR `destination2`="Spain" OR `destination3`="Spain")', NULL, FALSE);
}
if (isset($query_array['name']))
{
$this->db->where('name', $query_array['name']);
}
if (isset($query_array['location']))
{
$this->db->where('location', $query_array['location']);
}
$this->db->limit($limit, $offset);
$this->db->order_by($sort_by, $sort_order);
$ret['rows'] = $this->db->get()->result();
To be honest, I'm still not sure that's going to get the result you want. When you have to start adding numbers to database field names (destination1, destination2 etc...), that's normally a pretty good indication that your database design is flawed.