-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.php
46 lines (34 loc) · 1.09 KB
/
delete.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
40
41
42
43
44
45
46
<?php
/*
Symbol: CHn means location of code use find feature in your editor will be easy to find, CHn->CHn means must look at both code
To make it work on your project config these: CH1, CH2, CH3
*/
header("Contrnt-Type: application/json");
require_once("connection.php");
$response = array();
// for delete data must use id of that spacifi row
// (CH1)
if (isset($_POST["row_id"])) {
// CH2->CH4
$id = $_POST["row_id"];
// CH3
$query = "DELETE FROM table_name WHERE id = ?";
$query = $connection->prepare($query);
// CH4
$query->bind_param("i", $id);
if ($query->execute()) {
$response["error"] = false;
$response["message"] = "Delete succesfully";
$response["response_code"] = 200;
} else {
$response["error"] = true;
$response["message"] = "Delete FAILED";
$response["response_code"] = 400;
}
} else {
$response["error"] = false;
$response["message"] = "There is no required";
$response["response_code"] = 400;
}
echo json_encode($response);
?>