forked from richasdy/vietgram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeed.php
More file actions
217 lines (215 loc) · 10.7 KB
/
Copy pathfeed.php
File metadata and controls
217 lines (215 loc) · 10.7 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><?php echo isset($_GET['search']) ? $_GET['search'] . " " : "Feed " ?>| Vietgram</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="css/styles.css">
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<?php
session_start();
if (!isset($_SESSION['username']))
header('location:index.php');
?>
</head>
<body>
<nav class="navigation">
<div class="navigation__column">
<a href="feed.php">
<!-- Master branch comment -->
<img src="images/logo.png" />
</a>
</div>
<div class="navigation__column">
<i class="fa fa-search"></i>
<form action="feed.php" method="get">
<input type="text" placeholder="Search" name="search">
</form>
</div>
<div class="navigation__column">
<ul class="navigations__links">
<li class="navigation__list-item">
<a href="explore.html" class="navigation__link">
<i class="fa fa-compass fa-lg"></i>
</a>
</li>
<li class="navigation__list-item">
<a href="#" class="navigation__link">
<i class="fa fa-heart-o fa-lg"></i>
</a>
</li>
<li class="navigation__list-item">
<a href="profile.php" class="navigation__link">
<i class="fa fa-user-o fa-lg"></i>
</a>
</li>
<li class="navigation__list-item">
<a href="logout.php" class="navigation__link">
<i class="fa fa-sign-out fa-lg"></i>
</a>
</li>
</ul>
</div>
</nav>
<main id="feed">
<?php
if (isset($_GET['search'])) {
include 'connection.php';
$search = $_GET['search'];
$query = mysqli_query($conn, "SELECT * FROM PHOTOS JOIN USERS USING(USERNAME) WHERE CAPTION LIKE '%$search%'");
$result = mysqli_num_rows($query);
if ($result > 0) {
while ($res = mysqli_fetch_array($query)) { ?>
<div class="photo">
<header class="photo__header">
<img src="images/ya.jpg" class="photo__avatar" />
<div class="photo__user-info">
<span class="photo__author"><?php echo $res['username'] ?></span>
<span class="photo__location">Bestechung</span>
</div>
</header>
<img src="<?php echo $res['url'] ?>" style="width: 100%" />
<div class="photo__info">
<div class="photo__actions">
<span class="photo__action">
<i class="fa fa-heart-o fa-lg"></i>
</span>
<span class="photo__action">
<i class="fa fa-comment-o fa-lg"></i>
</span>
</div>
<span class="photo__likes"><?php echo $res['likes'] ?> likes</span>
<!-- photo caption -->
<ul class="photo__comments">
<li class="photo__comment">
<span class="photo__comment-author"><?php echo $res['username'] ?></span> <?php echo $res['caption'] ?>
</li>
</ul>
<ul class="photo__comments photo__add-comment-container">
<li class="photo__comment">
<span class="photo__comment-author">serranoarevalo</span> love this!
</li>
</ul>
<span class="photo__time-ago">2 hours ago</span>
<div class="photo__add-comment-container">
<textarea name="comment" placeholder="Add a comment..."></textarea>
<i class="fa fa-ellipsis-h"></i>
</div>
</div>
</div> <?php
}
} else
echo "<h6 class='lead'>No result for ". $_GET['search'] . "</h6>";
} else { ?>
<div class="photo">
<header class="photo__header">
<img src="images/ya.jpg" class="photo__avatar" />
<div class="photo__user-info">
<span class="photo__author">fajarnoorilham</span>
<span class="photo__location">Telkom University</span>
</div>
</header>
<img src="images/zayn.jpg" />
<div class="photo__info">
<div class="photo__actions">
<span class="photo__action">
<i class="fa fa-heart-o fa-lg"></i>
</span>
<span class="photo__action">
<i class="fa fa-comment-o fa-lg"></i>
</span>
</div>
<span class="photo__likes">45 likes</span>
<!-- photo caption -->
<ul class="photo__comments">
<li class="photo__comment">
<span class="photo__comment-author">Nissa Sabyan</span> Subhanalloh calon Imanku
</li>
</ul>
<ul class="photo__comments photo__add-comment-container">
<li class="photo__comment">
<span class="photo__comment-author">Pevita Pearce</span> love you
</li>
</ul>
<span class="photo__time-ago">2 hours ago</span>
<div class="photo__add-comment-container">
<textarea name="comment" placeholder="Add a comment..."></textarea>
<i class="fa fa-ellipsis-h"></i>
</div>
</div>
</div>
<div class="photo">
<header class="photo__header">
<img src="images/avatar.jpg" class="photo__avatar" />
<div class="photo__user-info">
<span class="photo__author">ilham</span>
<span class="photo__location">Pulau Kucing</span>
</div>
</header>
<img src="images/kucing.jpg" />
<div class="photo__info">
<div class="photo__actions">
<span class="photo__action">
<i class="fa fa-heart-o fa-lg"></i>
</span>
<span class="photo__action">
<i class="fa fa-comment-o fa-lg"></i>
</span>
</div>
<span class="photo__likes">45 likes</span>
<ul class="photo__comments">
<li class="photo__comment">
<span class="photo__comment-author">mamang racing</span> Lucu
</li>
</ul>
<span class="photo__time-ago">2 hours ago</span>
<div class="photo__add-comment-container">
<textarea name="comment" placeholder="Add a comment..."></textarea>
<i class="fa fa-ellipsis-h"></i>
</div>
</div>
</div> <?php
}
?>
</main>
<footer class="footer" id="footer">
<div class="footer__column">
<nav class="footer__nav">
<ul class="footer__list">
<li class="footer__list-item"><a href="#" class="footer__link">About Us</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Support</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Blog</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Press</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Api</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Jobs</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Privacy</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Terms</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Directory</a></li>
<li class="footer__list-item"><a href="#" class="footer__link">Language</a></li>
</ul>
</nav>
</div>
<div class="footer__column">
<span class="footer__copyright">© 2017 Vietgram</span>
</div>
</footer>
<style>
.not_found {
position: fixed;
width: 100%;
bottom: 0;
left: 16%;
}
</style>
</body>
<script>
<?php
if (isset($_GET['search']) && $result == 0) { ?>
$('.footer').replaceWith('<div class=\'footer not_found\'>' + $('.footer').html() +'</div>'); <?php
}
?>
</script>
</html>