forked from DEVanand69/Shuttergram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
86 lines (79 loc) · 3.72 KB
/
search.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
<?php
session_start();
require("bootstrap.php");
require("conn.php");
$myusername= $_SESSION['username'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<? require("bootstrap.php");
require("head.php"); ?>
<!-- for font -->
<link href="https://fonts.googleapis.com/css?family=Exo+2" rel="stylesheet">
<!-- for setting logo -->
<link rel='stylesheet' href='https://use.fontawesome.com/releases/v5.4.2/css/all.css'>
<!-- for logout logo -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <title>Document</title>
<link rel="stylesheet" href="search.css">
</head>
<body>
<?php require("searchbar.php"); ?>
<h1 class="h text-center">EXPLORE OTHER ACCOUNTS</h1>
<div class="container">
<?php
if(!$conn){
die("Error connecting to the database");
}else{
//query for retriving the posts
$query = "SELECT * from post ORDER BY postTime DESC";
$posts = mysqli_query($conn,$query);
//executing query
if(mysqli_num_rows($posts) > 0){ //if query is successful
//traversing and displaying posts
while($row = mysqli_fetch_assoc($posts)){
$username = $row['postUser'];
$dpquery = "SELECT dp from user WHERE username = '$username'";
$result = mysqli_query($conn,$dpquery);
$dpvar = mysqli_fetch_assoc($result);
$dp = $dpvar['dp'];
$postId = $row['postId'];
$queryLikes = "SELECT count(post) from likes WHERE post='$postId'";
$resultLikes = mysqli_query($conn,$queryLikes);
$resultLikes = mysqli_fetch_assoc($resultLikes);
$resultLikes = $resultLikes['count(post)'];
?>
<div class="card postCard">
<div class="card-header">
<div class="row">
<div class="col-sm-1"><img src="<?php echo $dp; ?>" class="rounded-circle postImg" alt="Profile"></div>
<div class="col-sm-11 h4 align-self-center postTitle"><?php echo $row['postUser']; ?></div>
</div>
</div>
<div class="card-body text-center">
<img src="<?php echo $row['media']; ?>" class="img-fluid" alt="Sorry, this image is unavailable at the moment" data-postId = "<?php echo $row['postId']; ?>">
</div>
</div>
<?php
} //closing bracket of traversing posts for loop
}else{
//if Number of Posts available is 0
?>
<div class="jumbotron jumbotron-fluid">
<div class="h2 text-center">
No more posts to show
</div>
<center>
<iframe src="https://giphy.com/embed/X8yP0AgGK0GQZaVXz9" frameBorder="0" class="giphy-embed img-fluid"></iframe>
</center>
<div class="h3 text-center muted">Come Back Later</div>
</div>
<?php
}
}
?>
</div>
<br><br><br><br><br><br>
<?php require("footbar.php"); ?>
</body>
</html>