-
Notifications
You must be signed in to change notification settings - Fork 1
/
post.php
122 lines (104 loc) · 4.16 KB
/
post.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
<?php
require_once 'post_conn.php';
@$view_all = $_GET["view_all"];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="font/css/all.min.css">
<link rel="stylesheet" href="post.css">
<title>post page</title>
</head>
<body>
<?php
require_once 'header.php';
?>
<main>
<?php
$sql = "SELECT * FROM posts";
$result = $conn_post->query($sql);
while($row = mysqli_fetch_assoc($result)){
?>
<div class="post_card">
<div class="header">
<div class="profile_image"><?php echo $row["client_name"][0]; ?></div>
<div class="header_name">
<div><h3><?php echo $row["client_name"]; ?></h3><span>is with</span><h3><?php echo $row["tag_name"]; ?></h3></div>
<p>53m</p>
</div>
</div>
<div class="image">
<img src="<?php echo $row["post_image"]; ?>">
</div>
<div class="reaction">
<div class="status">
<div id="like_num<?php echo $row["post_id"]; ?>"><?php echo $row["like_num"]; ?></div>
<div id="comment_num<?php echo $row["post_id"]; ?>"><?php
if($row["comment_num"] >0){
echo $row["comment_num"]." comments";
}
?>
</div>
</div>
<div class="icons">
<?php
$post_id = $row['post_id'];
@$sql_like = "SELECT * FROM post_like WHERE post_id = $post_id and client_id = $client_id";
@$like_check = $conn_post->query($sql_like);
if(@$like_check->num_rows == 0){
$like_status = "like";
}else{
$like_status = "liked";
}
?>
<div onclick="like(<?php echo $row['post_id']; ?>)" class="<?php echo $like_status; ?>"><i id="thumb<?php echo $row["post_id"]; ?>" class="fas fa-thumbs-up"></i> Like </div>
<div><i class="far fa-comment-alt"></i> Comment <?php
if($row["comment_num"] >0){
echo $row["comment_num"];
}
?></div>
<div><i class="fas fa-share"></i> Share</div>
</div>
</div>
<div class="comment_section">
<form action="post.php">
<input type="text" name="comment" data-id="<?php echo $row["post_id"]; ?>" class="write_comment" placeholder="Write Comment">
<button class="send_comment"><i class="fas fa-paper-plane"></i></button>
</form>
</div>
<div class="reply">
<?php
if($view_all == $row["post_id"]){
@$sql_comment = "SELECT * FROM `comment` ORDER BY comment_id DESC";
@$result_comment = $conn_post->query($sql_comment);
}else{
@$sql_limit = "SELECT * FROM `comment` ORDER BY comment_id DESC LIMIT 3";
@$result_comment = $conn_post->query($sql_limit);
}
while(@$row_comment = mysqli_fetch_assoc($result_comment)){
if(@$row_comment["post_id"] == $row["post_id"]){
?>
<div class="each_reply">
<div class="comment_image"><?php echo @$row_comment["client_name"][0]; ?></div>
<div class="comment_note">
<h3><?php echo @$row_comment["client_name"]; ?></h3>
<div class="comment"><?php echo @$row_comment["written_comment"]; ?></div>
</div>
</div>
<?php
}
}
?>
<a href="post.php?view_all=<?php echo $row["post_id"]; ?>" class="see_all">See all</a>
</div>
</div>
<?php
}
?>
</main>
<script src="post.js"></script>
</body>
</html>