-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_style_data.php
More file actions
65 lines (36 loc) · 1.56 KB
/
delete_style_data.php
File metadata and controls
65 lines (36 loc) · 1.56 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
include("connect.php");
$link=Connection();
$styleID = isset($_POST['styleID']) ? $_POST['styleID'] : null;
// //Required due to a space in the URL, without this php unlink() wont work, also need to change / to \
// $imageLocation = str_replace(" ","",$imageLocation);
// $imageLocation = str_replace("/","\\", $imageLocation);
// $imageLocation = getcwd()."\\".$imageLocation;
$get_style_number_query = "SELECT styledata.styleNumber FROM `styledata` Where styledata.styleID ='".$styleID."'";
$styleNumberResult=mysqli_query($link,$get_style_number_query);
if($styleNumberResult === FALSE) {
die(mysqli_error($link)); // TODO: better error handling
}
$styleNumber = "";
while($row = mysqli_fetch_array($styleNumberResult)) {
$styleNumber = $row['styleNumber'];
}
$delete_styledata_query="DELETE FROM `styledata` WHERE `styleID`= '".$styleID."' ";
$result = mysqli_query($link,$delete_styledata_query) or die(mysqli_error($link));
//After deleting styledata row, particular style table need to be dropped
$drop_style_table_query = "DROP TABLE ".$styleNumber." ";
$result2 = mysqli_query($link,$drop_style_table_query) or die(mysqli_error($link));
//Later : No need to remove the image from the folder
//Need to remove the image from the StyleImages folder
// if (!unlink($imageLocation)){
// $result3 = "Error deleting $imageLocation";
// }
// else{
// $result3 = "Deleted $imageLocation";
// }
if($result==1 && $result2==1){
$resultString = "Deleted all the records of the style with style number ".$styleNumber;
}
mysqli_close($link);
echo $resultString;
?>