-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeletefromsql.php
38 lines (34 loc) · 1.04 KB
/
deletefromsql.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
<?php
//This php script is responsible for saving the draggable tasks to the Database
require "php_config.php";
$inID = $_REQUEST["q"];
function checkDatabase($link, $inID){
$sql="SELECT * FROM example where id={$inID}";
if($result = $link->query($sql)){
while($row=$result->fetch_assoc()){
if($row!=null){
//The result has already been added to the table
return 1;
}
}
}
}
//This function is responsible for updating draggables if they already have been added
function deleteDraggable($link, $inID){
$sql = "DELETE FROM example WHERE id=?";
if($stmt = mysqli_prepare($link, $sql)){
$stmt->bind_param("i", $inID);
$stmt->execute();
$stmt->close();
$link->close();
}
}
//Check that we aren't being given nothing...
if($inID != null){
//Now Check if the Task has already been added to the Database, if so we need to alter
if(checkDatabase($link, $inID) == 1){
//Item has already been added to the database, instead update the corrosponding record
deleteDraggable($link, $inID);
}
}
?>