-
Notifications
You must be signed in to change notification settings - Fork 0
/
friends.php
69 lines (68 loc) · 2.5 KB
/
friends.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
<?php
require 'functions/functions.php';
session_start();
// Check whether user is logged on or not
if (!isset($_SESSION['user_id'])) {
header("location:index.php");
}
// Establish Database Connection
$conn = connect();
?>
<!DOCTYPE html>
<html>
<head>
<title>mySocial - Friends</title>
<link rel="stylesheet" type="text/css" href="resources/main.css">
<style>
.frame a{
text-decoration: none;
color: #4267b2;
}
.frame a:hover{
text-decoration: underline;
}
</style>
</head>
<body>
<?php include 'includes/navbar.php'; ?>
<div class="container">
<h1 class="login-signup-header">Friends</h1>
<?php
echo '<center>';
$sql = "SELECT users.user_id, users.user_name, users.user_gender
FROM users
JOIN (
SELECT friendship.user1_id AS user_id
FROM friendship
WHERE friendship.user2_id = {$_SESSION['user_id']} AND friendship.friendship_status = 1
UNION
SELECT friendship.user2_id AS user_id
FROM friendship
WHERE friendship.user1_id = {$_SESSION['user_id']} AND friendship.friendship_status = 1
) userfriends
ON userfriends.user_id = users.user_id";
$query = mysqli_query($conn, $sql);
$width = '168px';
$height = '168px';
if($query){
if(mysqli_num_rows($query) == 0){
echo '<div class="post">';
echo 'You don\'t yet have any friends.';
echo '</div>';
} else {
while($row = mysqli_fetch_assoc($query)){
echo '<div class="frame">';
echo '<center>';
include 'includes/profile_picture.php';
echo '<br>';
echo '<a href="profile.php?id=' . $row['user_id'] . '">' . $row['user_name'] . '</a>';
echo '</center>';
echo '</div>';
}
}
}
echo '</center>';
?>
</div>
</body>
</html>