示例#1
0
    $message = "";
    $food_or_drink;
    $f_o_d == 0 ? $food_or_drink = "FOOD" : ($food_or_drink = "DRINK");
    /* echo "item: " . $item_name . "\n" .
       "price: " . $price . "\n" .
       "quantity: " . $quantity . "\n" .
       "stock_count: " . $stock_count . "\n" .
       "age_check: " . $age_check . "\n" .
       "food or drink: " . $food_or_drink . "\n";*/
    $validName = !empty($item_name);
    $validPrice = is_numeric($price) && $price > 0;
    $validQuantity = is_numeric($quantity) && $quantity >= 0;
    if ($validName && $validPrice && $validQuantity) {
        $insertedItem = insertItem($item_name, $price, $quantity, $stock_count, $age_check, $food_or_drink, $con);
        if ($insertedItem[0]) {
            $newItemID = getItemID($item_name, $con);
            foreach ($_POST['pages'] as $check) {
                insertItemPagePosition($newItemID, $check, $con);
            }
        }
        // isInserted
        $message .= "Successfully Added To Database!";
    } else {
        $message .= "NOT VALID\n name " . $validName . "\n price " . $validPrice . "\n quantity " . $validQuantity . "\n";
    }
}
// if post
$array = selectPages($con);
mysqli_close($con);
?>
<!DOCTYPE html>
            $item->id = $row["ID"];
            $array[] = $item;
        }
    } else {
        printf("no results!");
    }
    mysqli_free_result($result);
    return $array;
}
$con = mysqli_connect("dbhost.cs.man.ac.uk", "mbbx9mg3", "Fincherz+2013") or die("Error " . mysqli_error($link));
mysqli_select_db($con, "mbbx9mg3");
if (isset($_POST["submit_button"])) {
    $itemsList = $_POST['items'];
    $message = "";
    foreach ($_POST['items'] as $check) {
        $newItemID = getItemID($check, $con);
        removeItem($newItemID, $con);
    }
    $message = "Removed Successfully!";
}
// isInserted
$array = selectItems($con);
mysqli_close($con);
?>
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    } else {
        printf("no results!");
    }
    mysqli_free_result($result);
    return $array;
}
$con = mysqli_connect("dbhost.cs.man.ac.uk", "mbbx9mg3", "Fincherz+2013") or die("Error " . mysqli_error($link));
mysqli_select_db($con, "mbbx9mg3");
$validNewAmount = false;
if (isset($_POST["submit_button"])) {
    $itemSelected = $_POST['item'];
    $newAmount = $_POST['newAmount'];
    $message = "";
    $validNewAmount = is_numeric($newAmount) && $newAmount >= 0;
    if ($validNewAmount) {
        $id = getItemID($itemSelected, $con);
        updateStock($id, $newAmount, $con);
        $message = "Stock updated successfully!";
    } else {
        $message = "Please check your input again!\n  is int: " . is_int($newAmount) . ", >= 0 : " . ($newAmount >= 0) . "";
    }
}
// isInserted
$array = selectItems($con);
mysqli_close($con);
?>
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.