Example #1
0
$editRecipe;
if (isset($_GET['addRecipe'])) {
    //new recipe
    $editRecipe = 0;
    require_once "views/edit_recipe.php";
    die;
} else {
    if (isset($_GET['edit'])) {
        require_once "models/DB.php";
        require_once "models/Recipe.php";
        require_once "models/Ingredient.php";
        require_once "models/units_of_measure.php";
        require_once "models/Step.php";
        //pull ingredients and units of measure alphabetically from database
        $ing = Ingredient::findAll($dbh);
        $units = units_of_measure::findAll($dbh);
        $newEntry = new Recipe();
        $newEntry->find($_GET['edit'], $dbh);
        $steps = Step::findAllSteps($dbh, $_GET['edit']);
        $ingredients = Ingredient::findAllIngredients($dbh, $_GET['edit']);
        $editRecipe = 1;
        require_once "views/edit_recipe.php";
        die;
    }
}
// Route 1: user comes here to add a new recipe, show them a blank form
// Route 2: user comes here to edit a specific recipe
//   (you'll need to grab that id from the query string)
// Route 3a: user entered a new recipe details and is trying to save it
//   create an object, set values, validate and save, just like in the lab
//   if all is well, send to ShowRecipe to see the added recipe
Example #2
0
echo $details->prep_time;
?>
 min.</p>
<p><label>Total Time:</label> <?php 
echo $details->total_time;
?>
min.</p>

<h3>Ingredients</h3>

<ul>
<?php 
foreach ($riu as $I) {
    ?>
	<li><?php 
    echo $I->amount . " " . units_of_measure::findName($I->unit_id, $dbh) . " " . Ingredient::findName($I->ingredient_id, $dbh);
    ?>
</li>
<?php 
}
?>
</ul>

<h3>Steps</h3>

<ul>
<?php 
foreach ($steps as $s) {
    ?>
	<li><?php 
    echo $s->text;