Page 39 - 3-2
P. 39
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
// check for required fields
if (isset($_POST['code'])) {
$code = $_POST['code'];
// connecting to db
// $db = new DB_CONNECT();
// mysql update row with matched pid
$result = mysqli_query($con, "DELETE FROM mdp_menu WHERE code = $code");
// check if row deleted or not
if (mysqli_affected_rows($con) > 0) {
// successfully updated
$response["success"] = 1;
$response["message"] = "Product successfully deleted";
// echoing JSON response
echo json_encode($response);
} else {
// no product found
$response["success"] = 0;
$response["message"] = "No product found";
// echo no users JSON
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
mysqli_close($con);
?>
- 39 -