-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeleteTheKeyword.php
More file actions
35 lines (26 loc) · 1.12 KB
/
deleteTheKeyword.php
File metadata and controls
35 lines (26 loc) · 1.12 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
<?php
include_once 'db_configuration.php';
if (isset($_POST['keyword'])) {
$keyword = mysqli_real_escape_string($db, $_POST['keyword']);
// Get the keyword ID for deletion from the question_keywords table
$getKeywordID = "SELECT id FROM keywords
WHERE keyword = '$keyword'";
$result = mysqli_query($db, $getKeywordID);
if ($result && mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$keywordID = $row['id']; // Extract the keyword ID from the result row
// Delete from the keywords table
$deleteKeywords = "DELETE FROM keywords
WHERE keyword = '$keyword'";
if (mysqli_query($db, $deleteKeywords)) {
// Delete from the question_keywords table using the keyword ID
$deleteQuestionKeywords = "DELETE FROM question_keywords
WHERE keyword_id = '$keywordID'";
if (mysqli_query($db, $deleteQuestionKeywords)) {
header('location: keywords_list.php?keywordDeleted=Success');
exit();
}
}
}
}
?>