-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteServices.php
39 lines (38 loc) · 1.71 KB
/
deleteServices.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require_once 'dbh.inc.php';
$delServices = $_GET['servicesId'];
$delVideosQuery = "SELECT * FROM videos WHERE servicesId='$delServices'";
$videosResult = mysqli_query($conn, $delVideosQuery);
if (mysqli_num_rows($videosResult) > 0) {
while ($row = mysqli_fetch_array($videosResult)) {
$createDeletePathVideos = "../../upload/" . $row['videoFile'];
if (unlink($createDeletePathVideos)) {
$delVideosQuery = "DELETE FROM videos WHERE servicesId='$delServices'";
$result = mysqli_query($conn, $delVideosQuery) or die("Query Unsuccessful.");
}
}
$query = "SELECT * FROM services WHERE servicesId='$delServices'";
$run = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($run);
$createDeletePath = "../../upload_img/" . $row['servicesImg'];
if (unlink($createDeletePath)) {
$delServicesQuery = "DELETE FROM services WHERE servicesId = '$delServices'";
$result = mysqli_query($conn, $delServicesQuery) or die("Query Unsuccessful.");
header("location: ../service.php");
mysqli_close($conn);
}
} else {
$query = "SELECT * FROM services WHERE servicesId='$delServices'";
$run = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($run);
$createDeletePath = "../../upload_img/" . $row['servicesImg'];
if (unlink($createDeletePath)) {
$delServicesQuery = "DELETE FROM services WHERE servicesId = '$delServices'";
$result = mysqli_query($conn, $delServicesQuery) or die("Query Unsuccessful.");
header("location: ../service.php");
mysqli_close($conn);
} else {
header("location: ../service.php");
mysqli_close($conn);
}
}