-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview2.php
More file actions
89 lines (53 loc) · 1.51 KB
/
view2.php
File metadata and controls
89 lines (53 loc) · 1.51 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
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
<!DOCTYPE html>
<html>
<head>
<title>View Reviews</title>
</head>
<body>
<?php
if(!isset($_SESSION)){
session_start();
}
if(!isset($_SESSION["username"])){
header('Location: login.php');
exit();
}
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "travel";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$username = $_SESSION["username"];
if (isset($_POST['view'])) {
$username=$_SESSION['username'];
$place = mysqli_real_escape_string($conn, $_POST['cit']);
$sql = "SELECT * FROM data WHERE username!='$username' AND place='$place' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "REVIEWS ABOUT THE PLACE <br><br>";
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>Place</th> <th>Review</th> <th>Review By</th> <th>Likes</th><th></th> </tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['place'] . '</td>';
echo '<td>' . $row['descr'] . '</td>';
echo '<td>' . $row['username'] . '</td>';
echo '<td>' . $row['likes'] . '</td>';
echo '<td><a href="like.php?id=' . $row['id'] . '">Like</a></td>';
echo "</tr>";
}}
else {
echo "0 results";
}
$conn->close();
// close table>
echo "</table>";
}
?>
<br>
<p style="color: black;"><a href="home.php">Back to HomePage</a></p>
</body>
</html>