<<pre lang="xml">?php echo $_POST['term']; ?> <?php require_once("database.php"); $term = $_POST['term']; $sql = mysql_query("SELECT * FROM `Recipe` WHERE `ingredients` like '%$term%' or `ingredients` like '%$term%' or `ingredients` like '%$term%'") or die(mysql_error()); while ($row = mysql_fetch_array($sql)) { echo '<br/>'; echo '<br/>'; echo 'Category: '.$row['category']; echo '<br/>'; echo '<br/> Recipe Name: '.$row['recipename']; echo '<br/>'; echo '<br/> Ingredients: '.$row['ingredients']; echo '<br/>'; echo '<br/> Preparations: '.$row['preparations']; echo '<br/>'; echo '<br/> Cooking Time: '.$row['cookingtime']; echo '<br/>'; echo '<br/> Servings: '.$row['servings']; echo '<br/>'; echo '<br/> Optional Notes: '.$row['optionalnotes']; echo '<br/><br/>'; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <h1> Meal Finder</h1> <h2>Enter 3 ingredients</h2> <tr><td>I have:</td><td> <input type="text" name="ingredients" maxlength="40"> </td></tr> <tr><td>and:</td><td> <input type="text" name="ingredients" maxlength="50"></td></tr> <tr><td>and:</td><td> <input type="text" name="ingredients" maxlength="50"> </td></tr> <tr> <td align="left"> </td></tr> </table> <input type="submit" name="submit" value="Submit" /> </form> </body> </html
ingredient1
ingredient2
ingredient3
WHERE `ingredients` like '%$term%' or `ingredients` like '%$term%' or `ingredients` like '%$term%'
or
and
"SELECT * FROM `Recipe` WHERE `ingredients` like '%$ingredient1%' and `ingredients` like '%$ingredient2%' and `ingredients` like '%$ingredient3%'"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)