I am trying to make a search box which will take three parameters and will list all the products related to them. But the like wild card is not working. My code is as follow:
public function search($textstring, $category, $college, $limit, $offset)
{
$sql = "SELECT * FROM ads WHERE Category = ? AND College_id = ? AND
AdTitle = ?";
$query = $this->db->limit($limit, $offset)
->query($sql, array($category, $college, '%' . $textstring . '%'));
echo "<pre>";
print_r($query);
print_r($textstring);
echo "</pre>";
return $query->result_array();
}
When I search for college and category parameters it works, but when I include text string it is not working.
Change = to Like
, like below in your query
$sql = "SELECT * FROM ads WHERE Category = ? AND College_id = ? AND
AdTitle LIKE ?";