forked from jashgopani/Shuttergram
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathprofile.php
127 lines (116 loc) · 6.06 KB
/
profile.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
<?php
session_start();
$username=$_SESSION['username'];
require("bootstrap.php");
require("conn.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php require("head.php"); ?>
<!-- for inline icons -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns" crossorigin="anonymous">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="profile.css">
</head>
<body>
<?php include("navbar.php"); ?>
<div class="container">
<br>
<div class="container">
<div class="row">
<div class="col-4 text-center" >
<img src="shuttergramDefault.png" class="img-thumbnail rounded-circle" alt="profilepic" id="profilePic">
</div>
<div class="col-8 text-center">
<div class="row justify-content-center">
<!-- <div class="col-3"></div> -->
<div class="col-3">
<span id="username"><b><?php echo $_SESSION['username']; ?></b></span>
</div>
<div class="col-3">
<a name="editProfile" id="editProfile" class="btn btn-outline-dark btn-sm" href="#" >edit profile</a>
<a href="insights.php" name="insights" id="insights" class="btn btn-outline-dark btn-sm" href="#" >INSIGHTS</a>
</div>
<!-- <div class="col-3"></div> -->
</div>
<br>
<div class="row justify-content-center ">
<div class="col-2">345<br>followers</div>
<div class="col-2"><?php
$query = "SELECT count(media) FROM post WHERE postUser='".$username."'";
$result = mysqli_query($conn,$query);
$value = mysqli_fetch_assoc($result);
echo $value['count(media)'];
?><br>posts</div>
<div class="col-2">454<br>following</div>
</div>
<br>
<div class="row justify-content-center">
<div class="col-10">
<?php
$query = "SELECT description FROM user WHERE username='".$username."'";
$result = mysqli_query($conn,$query);
$value = mysqli_fetch_assoc($result);
echo $value['description'];
?>
</div>
</div>
</div>
</div>
</div>
<hr>
<div class="container">
<div class="row row-eq-height" >
<?php
if(!$conn){
die("Error connecting to the database. ERROR: ".mysqli_connect_errno());
}else{
//query for retriving the user posts
$postquery = "SELECT * from post WHERE postUser='$username' ORDER BY postTime DESC";
$posts = mysqli_query($conn,$postquery);
//executing query
if(mysqli_num_rows($posts) > 0){ //if query is successful
//traversing and displaying user posts
while($row = mysqli_fetch_assoc($posts)){
$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="col-4">
<div class="row justify-content-around">
<div class="col-11 piccon text-center align-items-center">
<div class="imgfix">
<img src="<?php echo $row['media']; ?>" alt="Sorry, this image is unavailable at the moment" class="rounded img-fluid mx-auto" data-postId = "<?php echo $row['postId']; ?>">
</div>
<hr>
<span class="lnc"><i class="far fa-heart" data-liked="0"></i> <?php echo $resultLikes; ?> <i class="far fa-comment-alt"></i> 32</span>
</div>
</div>
</div>
<?php
} //closing bracket of traversing user posts while loop
}else{
//if Number of Posts available is 0
?>
<div class="container" style="color:white">
<div class="card ">
<center>
<iframe src="https://giphy.com/embed/iAQ5T6IdeyFn4zkVU5" width="480" height="480" frameBorder="0" class="giphy-embed img-fluid" allowFullScreen></iframe>
</center>
</div>
</div>
<?php
}
}
?>
</div>
</div>
</div>
<br><br><br><br><br><br>
<?php require("footbar.php"); ?>
</body>
</html>