-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpostComments.php
130 lines (102 loc) · 3.82 KB
/
postComments.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
include_once('./parts/entryCheck.php');
include_once('./server/db_connection.php');
include_once('./server/validation.php');
include_once('./server/functions.php');
$aboutSite = $connection->query('SELECT * FROM `system_data`');
$aboutSite = $aboutSite->fetch_array(MYSQLI_ASSOC);
?>
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<link rel='stylesheet' href='style.css'>
<link rel="stylesheet" href="./assets/css/all.min.css">
<link rel="stylesheet" href="./assets/css/fontawesome.css">
<link rel='preconnect' href='https://fonts.googleapis.com'>
<link rel='preconnect' href='https://fonts.gstatic.com' crossorigin>
<link href='https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap' rel='stylesheet'>
<link rel="shortcut icon" href="./assets/images/favicon.ico" type="image/x-icon">
<title>Post -
<?php echo $aboutSite['system_name']; ?>
</title>
<style>
#share-btn {
border: none;
background-color: white;
cursor: pointer;
}
#share-btn:hover {
background-color: rgba(0, 0, 0, 0.2);
}
.comment-inp {
display: flex;
width: 100%;
align-items: center;
justify-content: center;
}
.comment-inp button {
padding: 0px 5px 0px 5px;
}
.comment-inp input {
width: 100%;
}
</style>
<?php echo "<script>localStorage.setItem('mp-uid','" . $_SESSION['user']['uid'] . "')</script>"; ?>
</head>
<body>
<?php
include_once("./parts/navbar.php");
include_once("./parts/leftSidebar.php");
?>
<?php
if (isset($_GET['postId'])) {
$postId = htmlspecialchars($_GET['postId']);
$getCommentsQuery = "SELECT comments.*, users.uid, users.profile_picture, CONCAT(users.fname, ' ', users.lname) AS uname
FROM `comments`
INNER JOIN `users` ON comments.comment_by = users.uid
WHERE `post_id` = ?";
$stmt = $connection->prepare($getCommentsQuery);
$stmt->bind_param("i", $postId);
$stmt->execute();
$result = $stmt->get_result();
$comments = [];
while ($row = $result->fetch_assoc()) {
$comments[] = $row;
}
$stmt->close();
?>
<div class="mid-body">
<div>
<span>Comments - <?php echo count($comments); ?></span>
<hr>
<?php
if (count($comments) == 0) {
echo '<div style="border: 1px solid black"><a class="right-nav-item">
<span>No Comments found.</span>
</a></div>';
} else {
foreach ($comments as $comment) {
echo '<div style="border: 1px solid black"><a class="right-nav-item" href="user.php?id=' . $comment['uid'] . '">
<img class="right-nav-item-img" src="' . $comment['profile_picture'] . '">
<span>' . $comment['uname'] . '</span>
</a> <textarea disabled>
' . $comment['content'] . '
</textarea></div>';
}
}
?>
</div>
</div>
<?php
} else {
echo '<div style="border: 1px solid black"><a class="right-nav-item">
<span>No Comments found.</span>
</a></div>';
}
include_once("./parts/rightSidebar.php");
?>
<script src='./assets/scripts/jquery.js'></script>
</body>
</html>