-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathusers.php
More file actions
59 lines (49 loc) · 1.58 KB
/
Copy pathusers.php
File metadata and controls
59 lines (49 loc) · 1.58 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
<?php
//Include MySQL config info
include("config.php");
//Kick out users who are not logged in
include("authen.php");
//Start printing the page
include("header.php"); //Universal Start of Page
echo "<br/><br/><br/>";
$userid = $_SESSION['userid'];
$friendsquery="SELECT * FROM relations RIGHT JOIN userinfo ON
(userinfo.`userid` = relations.`userid1`
OR
userinfo.`userid` = relations.`userid2`)
AND
userinfo.`userid` != '$userid'
AND
relations.`relation` = '2'
WHERE
relations.`userid1` = '$userid'
OR
relations.`userid2` = '$userid';";
$friendsresult=mysql_query($friendsquery) or die('Unable to check for requests');
$numberoffriends = mysql_num_rows($friendsresult);
if ($numberoffriends)
{
echo "<h1>You have $numberoffriends Friends!</h1><table id='requeststable' class='requesttable' border=\"1\"><tr>";
while ($row = mysql_fetch_assoc($friendsresult))
{
//Get Info about this user
$friendid = $row["userid"];
//Check whether query was successful or not
$fname = $row['fname'];
$lname = $row['lname'];
//Print Table Content
echo "<tr><td><h3><a href='profile.php?id=$friendid' 'alt='$fname $lname's Profile'>$fname $lname</a></h3>";
if(isset($row['city']))
{
echo $row['city'];
echo ", ";
echo $row['state'];
}
echo "</td><td><button type=\"button\" onclick=\"window.location = 'deletefriend.php?id=$friendid';\">Delete Friend</button></td></tr>";
}
echo "</table>";
}
else echo "<h1>You have no Friends :(</h1>";
//Print off the Universal Footer of the page
include ("footer.php");
?>