<?php

include("connection.php");

$loc_id = intval($_GET['loc_id']);

$get = mysqli_query(
    $con,
    "SELECT image
     FROM tbl_location_pages
     WHERE loc_id='$loc_id'"
);

$row = mysqli_fetch_assoc($get);

if(!empty($row['image']))
{
    $imgPath =
    "./assets/images/location/" .
    $row['image'];

    if(file_exists($imgPath))
    {
        unlink($imgPath);
    }
}

mysqli_query(
    $con,
    "DELETE FROM tbl_location_pages
     WHERE loc_id='$loc_id'"
);

header(
    "Location:view_service_location_pages.php"
);

exit;
?>