Exemple #1
0
         $out .= "<form onSubmit=\"addCopy(); return false;\">";
         $out .= "<table><tr>";
         $out .= "<td>Name</td><td><input type=text id=name /></td></tr>";
         $out .= "<tr><td>Recipe to copy</td><td><select id=tocopy>";
         while ($w = $sql->fetch_array($r)) {
             $out .= "<option value={$w['1']}>{$w['0']}</option>";
         }
         $out .= "</select></td></tr>";
         $out .= "<tr><td><input type=submit value=Copy /></td></tr></table>";
         $out .= "</form>";
         break;
     case 'copyRecipe':
         $id = $_GET['id'];
         $name = $_GET['name'];
         $newid = copyRecipe($id, $name);
         $out .= displayRecipe($newid);
         break;
     case 'deleteRecipe':
         $id = $_GET['id'];
         $delQ1 = $sql->prepare("delete from recipes where id=?");
         $delR1 = $sql->execute($delQ1, array($id));
         $delQ2 = $sql->prepare("delete from ingredientList where recipeID=?");
         $delR2 = $sql->execute($delQ2, array($id));
         $delQ3 = $sql->prepare("delete from steps where recipeID=?");
         $delR3 = $sql->execute($delQ3, array($id));
         $delQ4 = $sql->prepare("delete from info where recipeID=?");
         $delR4 = $sql->execute($delQ4, array($id));
         $out .= "The recipe has been deleted";
         break;
 }
 // send output and return (so ajax doesn't get all the html')
Exemple #2
0
<?php

include '../../../config.php';
include_once 'dbconnect.php';
$sql = dbconnect();
$id = $_GET['id'];
echo displayRecipe($id);
// displays a recipe.  this may become 'ze doozy'
function displayRecipe($id)
{
    global $sql;
    $ret = "";
    $q = $sql->prepare("select r.name,r.upc,r.margin,r.price,r.servings,r.current_margin,i.info\n          from recipes as r, info as i where r.id=i.recipeID and r.id=?");
    $r = $sql->execute($q, array($id));
    $w = $sql->fetch_array($r);
    $name = $w['name'];
    $upc = $w['upc'];
    $margin = $w['margin'];
    $price = $w['price'];
    $servings = $w['servings'];
    $current_margin = $w['current_margin'];
    $info = $w['info'];
    $ret .= "<span style=\"font-size: 150%\"><b>{$name}</b></span><br />";
    $ret .= "\n<b>UPC</b>: {$upc}<br />";
    $ret .= "\n<b>Servings</b>: {$servings}<br />";
    $ret .= "<br /><b>Ingredients</b>";
    $ret .= "<div id=recipeingredients>";
    $ret .= getIngredients($id);
    $ret .= "</div>";
    $ret .= "<br /><br /><b>Steps</b>:";
    $ret .= "<div id=recipesteps>";
Exemple #3
0
 * can handle responses differently as needed.
 * a backtick separates request name from data
 */
$out = '';
if (isset($_GET['action'])) {
    // prepend request name & backtick
    $out = $_GET['action'] . "`";
    // switch on request name
    switch ($_GET['action']) {
        case 'viewRecipes':
            $catID = $_GET['catID'];
            $out .= getRecipes($catID);
            break;
        case 'displayRecipe':
            $id = $_GET['id'];
            $out .= displayRecipe($id);
            break;
        case 'multiply':
            $id = $_GET['id'];
            $mult = $_GET['multiplier'];
            $out .= getIngredients($id, $mult);
    }
    echo $out;
    return;
}
// returns a list of categories as a string
function getCategories()
{
    global $sql;
    $ret = "<b>Categories</b>:";
    $ret .= "<ul>";