Welcome Guest, Not a member yet? Register   Sign In
PHP search with spaces
#15

[eluser]theprodigy[/eluser]
[quote author="Kraig" date="1345860880"]I try the following the code and I get no results when there should be. The commented query works.

Code:
$key = trim($key);
  $keys = explode(" ", $key);
  
  $this->db->select('*');
  $this->db->from('upload');
  foreach($keys as $piece){
     $this->db->or_like('name', $piece);
  }
  $this->db->limit($start, $limit);
  $query = $this->db->get();
  //$query = $this->db->query("SELECT * FROM upload WHERE name LIKE '%".$key."%' LIMIT $start, $limit");
[/quote]

The only things I would do to this is:
1. No need for the select('*'). If you don't set the select, CI does this automatically.
2. Where are you setting your $start and $limit variables?


Messages In This Thread
PHP search with spaces - by El Forum - 08-22-2012, 07:30 PM
PHP search with spaces - by El Forum - 08-22-2012, 10:01 PM
PHP search with spaces - by El Forum - 08-22-2012, 10:14 PM
PHP search with spaces - by El Forum - 08-22-2012, 11:28 PM
PHP search with spaces - by El Forum - 08-23-2012, 02:51 PM
PHP search with spaces - by El Forum - 08-23-2012, 03:06 PM
PHP search with spaces - by El Forum - 08-24-2012, 06:16 AM
PHP search with spaces - by El Forum - 08-24-2012, 06:25 AM
PHP search with spaces - by El Forum - 08-24-2012, 11:28 AM
PHP search with spaces - by El Forum - 08-24-2012, 11:50 AM
PHP search with spaces - by El Forum - 08-24-2012, 05:02 PM
PHP search with spaces - by El Forum - 08-24-2012, 07:14 PM
PHP search with spaces - by El Forum - 08-24-2012, 07:35 PM
PHP search with spaces - by El Forum - 08-25-2012, 12:43 AM
PHP search with spaces - by El Forum - 08-26-2012, 01:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB