-
Notifications
You must be signed in to change notification settings - Fork 1
/
delete_answer.php
82 lines (63 loc) · 2.85 KB
/
delete_answer.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php include 'controllers/authController.php';
?>
<?php
$username=$_SESSION['username'];
$comment_id=$_GET['comment_id'];
$sql="SELECT `comment_sender_name` FROM `tbl_comment` WHERE `comment_id`='$comment_id'";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($result))
{
$asked=$row['comment_sender_name'];
if($asked==$username)
{
$hi="hi";
echo '<pre>' . print_r($hi, TRUE) . '</pre>';
$sql1="SELECT `post_id` FROM `tbl_comment` WHERE `comment_id`='$comment_id'";
$result1 = mysqli_query($conn, $sql1);
while($rows = mysqli_fetch_assoc($result1))
{
$post_id = $rows['post_id'];
}
$sql2="SELECT `comment_id` FROM `tbl_comment` WHERE `parent_comment_id`='$comment_id'";
$result2 = mysqli_query($conn, $sql2);
while($rows = mysqli_fetch_assoc($result2))
{
$comment_id_reply = $rows['comment_id'];
$sql="DELETE FROM `rating_info` WHERE `post_id`='$comment_id_reply'";
//echo '<pre>' . print_r($sql, TRUE) . '</pre>';
$result = mysqli_query($conn, $sql);
}
$sql="DELETE FROM `tbl_comment` WHERE `parent_comment_id`='$comment_id'";
$result = mysqli_query($conn, $sql);
$sql="DELETE FROM `tbl_comment` WHERE `comment_id`='$comment_id'";
$result = mysqli_query($conn, $sql);
$sql="DELETE FROM `rating_info` WHERE `post_id`='$comment_id'";
$result = mysqli_query($conn, $sql);
header("location: http://localhost/iwp/answers.php?post_id=$post_id");
}
}
// $sql1="SELECT `post_id` FROM `tbl_comment` WHERE `comment_id`='$comment_id'";
// $result1 = mysqli_query($conn, $sql1);
// while($rows = mysqli_fetch_assoc($result1))
// {
// $post_id = $rows['post_id'];
// }
//echo '<pre>' . print_r($post_id, TRUE) . '</pre>';
// $sql2="SELECT `comment_id` FROM `tbl_comment` WHERE `parent_comment_id`='$comment_id'";
// $result2 = mysqli_query($conn, $sql2);
// while($rows = mysqli_fetch_assoc($result2))
// {
// $comment_id_reply = $rows['comment_id'];
// $sql="DELETE FROM `rating_info` WHERE `post_id`='$comment_id_reply'";
// //echo '<pre>' . print_r($sql, TRUE) . '</pre>';
// $result = mysqli_query($conn, $sql);
// }
// $sql="DELETE FROM `tbl_comment` WHERE `parent_comment_id`='$comment_id'";
// $result = mysqli_query($conn, $sql);
// $sql="DELETE FROM `tbl_comment` WHERE `comment_id`='$comment_id'";
// $result = mysqli_query($conn, $sql);
// $sql="DELETE FROM `rating_info` WHERE `post_id`='$comment_id'";
// $result = mysqli_query($conn, $sql);
// header("location: http://localhost/iwp/answers.php?post_id=$post_id");
?>
<!-- <a href="#" class="text-dark ms-2" title="Edit"><i class="fa fa-pencil-square-o"> </i></a> -->