-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewComments.php
125 lines (110 loc) · 3.36 KB
/
viewComments.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
<?php
include_once "db_connection.php";
session_start();
if(!isset($_SESSION["loggedIn"]))
header("Location: index.php");
else if(isset($_SESSION["loggedIn"]) && $_SESSION["loggedIn"] == 0)
header("Location: index.php");
?>
<!DOCTYPE html>
<html>
<title>Comments Page</title>
<head><link rel="stylesheet" href="items.css"></head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel='stylesheet' href='https://use.fontawesome.com/releases/v5.7.0/css/all.css' integrity='sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ' crossorigin='anonymous'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
.checked {
color: orange;
}
</style>
<body>
<div class="logo">
<b> Lost & Found </b>
</div>
<div class="topnav">
<a href="index.php" style="float:right"><i class="fa fa-fw fa-home"></i>Home</a>
<a href="account.php" style="float:right"><i class="fa fa-fw fa-user"></i>Account</a>
<a href="institutions.php" style="float:right"><i class="fa fa-fw fa-globe"></i>Search Places</a>
<a href="items.php" style="float:right"><i class="fa fa-fw fa-search"></i>Search Items</a>
<a href="found.php" style="float:right"><i class='fas fa-hand-holding-heart'></i>Found Something</a>
</div>
<?php
$id = $_GET["id"];
$sqlUser = "SELECT Name, Rating FROM Users WHERE ID = '$id'";
$userResult = $conn->query($sqlUser);
$userRow = mysqli_fetch_assoc($userResult);
?>
<div class="row">
<div class="leftcolumn">
<div class="card">
<p><b>Name: </b> <?php echo($userRow["Name"]) ?></p>
<p><b>Rating: </b>
<?php
$stars = round($userRow["Rating"]);
for($index = 0; $index < $stars; $index++)
{
?>
<span class = "fa fa-star checked"></span>
<?php } ?>
<?php
for($index = 0; $index < (5 - $stars); $index++)
{ ?>
<span class = "fa fa-star"></span>
<?php
}
echo '(' . round($userRow["Rating"], 1) . ')';
?>
</p>
</div>
</div>
<div class="rightcolumn">
<?php
$sqlComment = "SELECT * FROM Ratings";
$commentResult = $conn->query($sqlComment);
$noOfComments = 0;
while($commentRow = $commentResult->fetch_assoc())
{
if($commentRow["CommentedID"] == $id)
{
$sql = "SELECT ID, Name FROM Users";
$result = $conn->query($sql);
while($row = $result->fetch_assoc())
{
if($row["ID"] == $commentRow["CommenterID"])
{
?>
<div class="card">
<h2>
<?php echo $row["Name"]; ?>
</h2>
<p class = "outset"><h4>
<?php
$stars = round($commentRow["Rating"]);
for($index = 0; $index < $stars; $index++)
{
?>
<span class = "fa fa-star checked"></span>
<?php } ?>
<?php
for($index = 0; $index < (5 - $stars); $index++)
{ ?>
<span class = "fa fa-star"></span>
<?php
} ?>
<br>
<?php echo $commentRow["Comment"]; ?>
</h4>
</p>
</div>
<?php
$noOfComments++;
}//if
}//while
}//if
}//while
if($noOfComments == 0)
echo "This user has no comments";
?>
</div>