-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreviews.php
More file actions
176 lines (155 loc) · 8.59 KB
/
reviews.php
File metadata and controls
176 lines (155 loc) · 8.59 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<html lang="en">
<head>
<title>Luxauto</title>
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" class=""accesskey=""rel="stylesheet">
<link rel="stylesheet" href="./css/reviews2.css">
<?php include './includes/bootstrap-header.php'; ?>
</head>
<body>
<?php include './includes/nav.php'; ?>
<div>
<div class="header-blue" style="background: url("https://i.imgur.com/POvH8Fx.png");">
<div class="container hero">
<div class="row">
<div class="col-12 col-lg-6 col-xl-5 offset-xl-1">
<h1>Let us know</h1>
<p>Your Reviews. </p><a href="addreview.php"><button class="btn btn-light btn-lg action-button" type="button">Add a Review</button></a></div>
<div class="col-md-5 col-lg-5 offset-lg-1 offset-xl-0 d-none d-lg-block phone-holder">
<div class="phone-mockup">
<div class="screen"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="testimonials-clean">
<div class="container">
<div class="intro">
<h2 class="text-center">User Reviews</h2>
</div>
<?php
session_start();
$review = $errormsg = "";
$success = true;
// Get member's id from session
$member_id = $_SESSION['memberid'];
global $member_id, $review, $error_msg, $success;
// Create database connection
$config = parse_ini_file('../../private/db-config.ini');
$conn = new mysqli($config['servername'], $config['username'], $config['password'], 'project1004');
// Check connection
if ($conn -> connect_error)
{
$errorMsg = "Connection failed: " . $conn -> connect_error;
$success = false;
}
// Prepare the statement
//date_default_timezone_set('Asia/Singapore');
$stmt = $conn -> prepare("SELECT * FROM reviews");
// Bind & execute the query statement
$stmt->execute();
$result = $stmt->get_result();
//$sql = "SELECT * FROM reviews";
//$result = $conn->query($sql);
if($result->num_rows > 0)
{
//$row = $result->fetch_assoc();
//$review_id = $row['id'];
//$member_id = $row['member_id'];
//$review = $row['review'];
//$datetime = $row['date_time'];
while ($rows = $result->fetch_assoc())
{
?>
<div class="row people" style="margin-left: 0px;margin-right: 0px;padding-top: 10px;padding-bottom: 10px;">
<div class="col-md-6 col-lg-4 item" style="max-width: 100%;margin-right: 10px;margin-left: 10px;min-width: 100%;height: 100%;margin-bottom: 0px;">
<div class="box">
<p class="description"><?php echo $rows['review']; ?></p>
</div>
<div class="author"><img class="rounded-circle" src="./images/logos/cat.gif">
<h5 class="name">Anonymous Member</h5>
<p class="title">Reviewed at <?php echo $rows['date_time']; ?></p>
</div>
<?php
if($member_id != null) {
?>
<div class="btn-toolbar">
<form action="addcomment.php" method="GET">
<input type="hidden" name="review_id" value="<?php echo $rows['id']; ?>">
<button class="btn btn-primary" type="submit">Add comment</button>
</form>
<?php
if ($member_id == $rows['member_id']) { //buttons are done
?>
<form action="editreview.php" method="GET">
<input type="hidden" name="review_id" value="<?php echo $rows['id'];?>">
<button class="btn btn-primary" type="submit">Edit Review</button>
</form>
<form action="deletereview.php" method="GET">
<input type="hidden" name="review_id" value="<?php echo $rows['id'];?>">
<button class="btn btn-primary" type="submit">Delete Review</button>
</form>
<?php
}
?>
</div>
<hr>
<?php
}
$statement = $conn -> prepare("SELECT * FROM comments WHERE review_id=?");
$statement->bind_param("s", $rows['id']);
$statement->execute();
$stresult = $statement->get_result();
if($stresult->num_rows > 0)
{
while ($strows = $stresult->fetch_assoc())
{
?>
<div class="box">
<p class="description"><?php echo $strows['comment'];?></p>
<div class="author"><img class="rounded-circle" src="./images/logos/cat.gif">
<h5 class="name">Anonymous Member</h5>
<p class="title">Commented on <?php echo $strows['date_time'];?></p>
</div>
</div>
<?php
if($member_id == $strows['member_id']) {
?>
<form action="editcomment.php" method="GET">
<input type="hidden" name="comment_id" value="<?php echo $strows['id'];?>">
<button class="btn btn-primary" type="submit">Edit Comment</button>
</form>
<form action="deletecomment.php" method="GET">
<input type="hidden" name="comment_id" value="<?php echo $strows['id'];?>">
<button class="btn btn-primary" type="submit">Delete Comment</button>
</form>
<?php
}
}
}?>
</div>
<div class="col">
<!-- <div class="author"><img class="rounded-circle" src="assets/img/cat.gif">
<h5 class="name">Ben Johnson</h5>
<p class="title">CEO of Company Inc.</p>
</div> -->
</div>
</div>
<?php
}
}
else
{
?>
<h4>There is no reviews yet.</h4>
<?php
}
$conn->close();
?>
</div>
</div>
<?php include "./includes/footer.php"; ?>
</body>
</html>