-
Notifications
You must be signed in to change notification settings - Fork 2
/
following.php
103 lines (85 loc) · 3.68 KB
/
following.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
<?php
/**
* Shows list of users who are following a particular user.
*
* @version PHP 8.0.12
* @since June 2022
* @author AtharvaShah
*/
session_start();
if(empty($_SESSION))
{
header("Location: login.php");
}
require "connection.php";
require "functions.php";
require "header.php";
$user_data = check_login($con);
$username = $user_data['user_name'];
?>
<!-------------------------------------------------------------------------------------
HTML PART
------------------------------------------------------------------------------------->
<!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">
<meta name="description" content="shows list of accounts followed by the user" />
<meta name="keywords" content="WYDRN, following" />
<title>WYDRN - Following</title>
<!--ORDER OF PLACING CSS CDN AND SCRIPT IS IMPORTANT. CUSTOM CSS COMES LAST AS WE OVERRIDE BOOTSTRAP CLASSES.-->
<link rel="icon" type="image/png" href="images/website/favicons/favicon-32x32.png" sizes="32x32">
<link rel="apple-touch-icon" href="images/website/favicons/apple-touch-icon.png">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link href="CSS/following.css" rel="stylesheet">
<link href="css/backToTop.css" rel="stylesheet">
</head>
<body>
<button onclick="topFunction()" id="BackToTopBtn" title="Go to top">⇑</button>
<?php
if(isset($_GET['user_name'])){
$follower=$_GET['user_name'];
}else{
$follower=$username;
}
//join query for social and user table where the matching criteria is follower_username and username
$sql="SELECT count(*) from `social` s LEFT JOIN `users` u ON s.followed_username=u.user_name where follower_username='$follower'";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result);
$count = $row[0];
?>
<div class="container">
<h1 class="h1count"><?php echo $count; ?> Following</h1>
<ul class="follow-ul">
<?php
$sql2 = "SELECT `followed_username`, `profile_pic` from `social` s LEFT JOIN `users` u ON s.followed_username=u.user_name where follower_username='$follower'";
$result = mysqli_query($con, $sql2);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
?>
<!-- DYNAMICALLY THE LIST OF ALL FOLLOWING USERS WITH PROFILE PIC AND LINK TO THEIR PROFILES -->
<li class='follow-li'>
<?php $profile_link="profile.php?user_name=".$row['followed_username'];?>
<a class="follow-a" href=<?php echo $profile_link; ?>>
<div class="flex-container" style="vertical-align:middle;">
<span class="follow-span">
<img src=<?php echo $row['profile_pic']; ?> class="follower-pfp">
</span>
<strong class="follow-username"><?php echo strtoupper($row['followed_username']); ?></strong>
</div>
</a>
</li>
<?php
}
}
?>
</ul>
</div> <!--Container DIV end.-->
<script src="js/backToTop.js"></script>
</body>
</html>
<?php
mysqli_close($con);
?>