-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreview.tpl.php
67 lines (62 loc) · 2.16 KB
/
review.tpl.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
<?php
declare(strict_types=1);
?>
<?php function drawReview(Restaurant $restaurant, array $reviews)
{ ?>
<h2>Send Your Feedback!</h2>
<?php
$count = 0;
if(sizeof($reviews) > 0) {?>
<div id="average">
<?php for($i = 0; $i < sizeof($reviews); $i++){
$count += $reviews[$i]->score;
}
$average = round($count/(sizeof($reviews)),2) ?>⭐
<?= $average ?><?="("?><?= sizeof($reviews) ?><?=")"?>
</div>
<?php } ?>
<div class="rate">
<h2>What do you think about <a href="../Pages/restaurant.php?id=<?=$restaurant->id?>"><span id=reviewRestaurantName><?= "$restaurant->name" ?></span></a> restaurant?</h2>
<h3>Rate:</h3>
<form class="reviewForm" name="form1" method="post">
<select name="score" class="form" id="score">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<h3>Leave a Comment:</h3>
<textarea class="reviewText" id="reviewText" rows="5" cols="60"></textarea><br>
<button type="submit" id="submitReview">Submit</button>
</form>
</div>
<?php } ?>
<?php function drawReviews(PDO $db,array $reviews)
{ ?>
<h2>See what other users think:</h2>
<?php
require_once('../Classes/user.class.php');
$count = 0;
if(sizeof($reviews) > 0) {
for($i = 0; $i < sizeof($reviews); $i++){
$user = User::getUser($db,$reviews[$i]->userId);
?>
<div id="userReview">
<p>
<span id=reviewUsername><?= $user->username?></span>
<?php for($j = 0; $j < intval($reviews[$i]->score); $j++) { ?>
⭐
<?php } ?>
<?php $count += $reviews[$i]->score ?>
<?= $reviews[$i]->reviewText?>
</p>
</div>
<?php }
}
else{ ?>
<div id="userReview2">
<p>There are no reviews yet 😞</p>
</div>
<?php } ?>
<?php } ?>