72 lines
2.0 KiB
PHP
72 lines
2.0 KiB
PHP
<?php
|
|
include "../../connect.php";
|
|
|
|
$id = filterRequest("id");
|
|
|
|
// Create an empty array to store the column-value pairs
|
|
$columnValues = array();
|
|
|
|
// Check if each column is set in the request and add it to the array
|
|
if (isset($_POST["kazan"])) {
|
|
$kazan = filterRequest("kazan");
|
|
$columnValues[] = "`kazan` = '$kazan'";
|
|
}
|
|
|
|
if (isset($_POST["comfortPrice"])) {
|
|
$comfortPrice = filterRequest("comfortPrice");
|
|
$columnValues[] = "`comfortPrice` = '$comfortPrice'";
|
|
}
|
|
|
|
if (isset($_POST["speedPrice"])) {
|
|
$speedPrice = filterRequest("speedPrice");
|
|
$columnValues[] = "`speedPrice` = '$speedPrice'";
|
|
}
|
|
|
|
if (isset($_POST["deliveryPrice"])) {
|
|
$deliveryPrice = filterRequest("deliveryPrice");
|
|
$columnValues[] = "`deliveryPrice` = '$deliveryPrice'";
|
|
}
|
|
if (isset($_POST["freePrice"])) {
|
|
$freePrice = filterRequest("freePrice");
|
|
$columnValues[] = "`freePrice` = '$freePrice'";
|
|
}
|
|
if (isset($_POST["latePrice"])) {
|
|
$latePrice = filterRequest("latePrice");
|
|
$columnValues[] = "`latePrice` = '$latePrice'";
|
|
}
|
|
|
|
if (isset($_POST["heavyPrice"])) {
|
|
$heavyPrice = filterRequest("heavyPrice");
|
|
$columnValues[] = "`heavyPrice` = '$heavyPrice'";
|
|
}
|
|
|
|
if (isset($_POST["adminId"])) {
|
|
$adminId = filterRequest("adminId");
|
|
$columnValues[] = "`adminId` = '$adminId'";
|
|
}
|
|
|
|
if (isset($_POST["createdAt"])) {
|
|
$createdAt = filterRequest("createdAt");
|
|
$columnValues[] = "`createdAt` = '$createdAt'";
|
|
}
|
|
|
|
if (isset($_POST["naturePrice"])) {
|
|
$naturePrice = filterRequest("naturePrice");
|
|
$columnValues[] = "`naturePrice` = '$naturePrice'";
|
|
}
|
|
|
|
// Construct the SET clause of the update query using the column-value pairs
|
|
$setClause = implode(", ", $columnValues);
|
|
|
|
$sql = "UPDATE `kazan` SET $setClause WHERE `id` = '$id'";
|
|
|
|
$stmt = $con->prepare($sql);
|
|
$stmt->execute();
|
|
|
|
if ($stmt->rowCount() > 0) {
|
|
// Print a success message
|
|
printSuccess($message = "Kazan data updated successfully");
|
|
} else {
|
|
// Print a failure message
|
|
printFailure($message = "Failed to update kazan data");
|
|
} |