I have 3 tables the ingredient(ingredient_id,name),menu(recipe_id,ingredient_id,category_id) and recipe(recipe_id, r_name,r_description).
ingredient_id name
1 Onion
2 Paul
3 Pepper
4 Oil
recipe_id ingredient_id category_id
1 3 1
1 4 1
2 3 1
2 4 1
recipe_id r_name r_description
1 Adobo yummy
2 Kaldereta yucky
What I want is if I search "Pepper, Oil" , the result should be the recipe that corresponds with the ingredients which is the adobo and kaldereta.
I had this tried but it is only static i want it dynamic and also i want to explode ingredient_name so that I could search multiple words.
public function get_halal()
{
$this->db->distinct();
$this->db->select('*');
$this->db->from('recipe');
$this->db->join('menu', 'menu.recipe_id = recipe.recipe_id');
$this->db->join('ingredient', 'ingredient.ingredient_id = menu.ingredient_id');
$this->db->where('menu.category_id = 1');
$this->db->like('ingredient.ingredient_name','Mango', 'both');
$query = $this->db->get();
return $query->result();
}