コード例 #1
0
ファイル: formbuyer.php プロジェクト: DmitriyOs/PHPLabs
function addElemToStorage()
{
    require_once "textstorageconnection.php";
    $mas = getArrayFromFile("buyers");
    $buyer = new buyer();
    $buyer->id = uniqid();
    $buyer->name = $_POST["addName"];
    $buyer->adress = $_POST["addAdress"];
    $buyer->phone = $_POST["addPhone"];
    $mas[count($mas)] = $buyer;
    writeArrayToFile("buyers", $mas);
}
コード例 #2
0
ファイル: formcar.php プロジェクト: DmitriyOs/PHPLabs
function addElemToStorage()
{
    require_once "textstorageconnection.php";
    $mas = getArrayFromFile("cars");
    $car = new Car();
    $car->id = uniqid();
    $car->brand = $_POST["addBrand"];
    $colors = "";
    foreach ($_POST["addColor"] as $currentColor) {
        $colors .= $currentColor;
        $colors .= ", ";
    }
    $colors = substr($colors, 0, -2);
    $car->color = $colors;
    $car->date = $_POST["addDate"]["month"] . "." . $_POST["addDate"]["year"];
    $car->price = $_POST["addPrice"];
    $car->percent = $_POST["addPercent"];
    $mas[count($mas)] = $car;
    writeArrayToFile("cars", $mas);
}
コード例 #3
0
ファイル: delete.php プロジェクト: DmitriyOs/PHPLabs
require_once "textstorageconnection.php";
$target;
$id = $_POST["id"];
$isDeleted = false;
switch ($_POST["deleteObject"]) {
    case "Car":
        $target = "cars";
        break;
    case "Owner":
        $target = "owners";
        break;
    case "Buyer":
        $target = "buyers";
        break;
}
$mas = getArrayFromFile($target);
foreach ($mas as $k => $v) {
    if ($v->id == $id) {
        $isDeleted = true;
        unset($mas[$k]);
    }
}
$mas = array_values($mas);
writeArrayToFile($target, $mas);
if ($isDeleted) {
    echo "<h4>Запись успешно удалена</h4>";
} else {
    echo "Запись не найдена";
}
?>
<form action=start.php method=POST role=form>
コード例 #4
0
ファイル: start.php プロジェクト: DmitriyOs/PHPLabs
    <link href="css/bootstrap.css" rel="stylesheet">
    <style>
        body {
            margin: 10px;
        }
    </style>
</head>
<body>
<?php 
require_once "objects.php";
require_once "sortRules.php";
require_once "filterHelp.php";
require_once "textstorageconnection.php";
$masCar = getArrayFromFile("cars");
$masOwner = getArrayFromFile("owners");
$masBuyer = getArrayFromFile("buyers");
if (isset($_POST["filter"])) {
    switch ($_POST["filter"]) {
        case "Car":
            filterCar();
            break;
        case "Owner":
            filterOwner();
            break;
        case "Buyer":
            filterBuyer();
            break;
    }
}
function filterCar()
{