Thursday, August 28, 2008

Recapping

Not sure if I have covered this in a previous post, but thought I better just mention that I have changed the format of the submit recipe form a bit.

When Phil and I were going through the search recipe function a few weeks ago it became evident that the option to have all recipes linked to three main ingredients (to accommodate an option to search for a recipe by a particular ingredient) was going to cause a real headache when trying to link the associated_ingredients_id with each recipe. So he and I agreed that it would be easier to just create a function which would search for ingredients LIKE which ever one you wanted. So the coding in the search for recipe form looks like this:

$query = "SELECT recipe_title AS Recipe, recipe_ingredients_list AS Ingredients, recipe_method AS Method FROM recipe WHERE category_id = $type AND recipe_ingredients_list LIKE '%".$_POST['ingredients']."%'ORDER BY recipe_title ASC, recipe_ingredients_list ASC, recipe_method ASC"

This then searches for any recipe which has an ingredient that is like the ingredient chosen in the search form. I also included an option to refine the search according to the category chosen.

This meant that I no longer had to include the checkbox option for assiciated ingredients in the submit a recipe form - this checkbox part of the form was also causing headaches. I had actually set up a small piece of javascript in the header.html template to handle this checkbox function. But will not need this anymore.

No comments: