-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlocal_history.patch
109 lines (96 loc) · 3.6 KB
/
local_history.patch
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
Index: gypsy/functions.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/gypsy/functions.php b/gypsy/functions.php
--- a/gypsy/functions.php
+++ b/gypsy/functions.php (date 1688639284282)
@@ -1,41 +1,41 @@
<?php
include_once 'func.php';
-?>
-<?php
session_start(); // Start the session
- if (isset($_GET['destination'])) {
- $destination = $_GET['destination'];
+if (isset($_GET['destination'])) {
+ $destination = $_GET['destination'];
- // Run the SQL query using the destination value
- $avquery = "SELECT user_rating FROM review WHERE destination = '" . $destination . "'";
+ // Run the SQL query using the destination value
+ $avquery = "SELECT user_rating FROM review WHERE destination = '" . $destination . "'";
- // Execute the query
- $avresult = $conn->query($avquery);
+ // Execute the query
+ $avresult = $conn->query($avquery);
- // Check if the query was successful
- if ($avresult && $avresult->num_rows > 0) {
- $avratings = array();
- while ($row = $avresult->fetch_assoc()) {
- $avratings[] = $row['user_rating'];
- }
+ // Check if the query was successful
+ if ($avresult && $avresult->num_rows > 0) {
+ $avratings = array();
+ while ($row = $avresult->fetch_assoc()) {
+ $avratings[] = $row['user_rating'];
+ }
- $totalrating = count($avratings);
- $averageRating = $totalrating > 0 ? array_sum($avratings) / $totalrating : 0;
- $avgrating = number_format($averageRating, 1);
+ $totalrating = count($avratings);
+ $averageRating = $totalrating > 0 ? array_sum($avratings) / $totalrating : 0;
+ $avgrating = number_format($averageRating, 1);
- // Store the average rating count in session
- $_SESSION['averageRating'] = $avgrating;
+ // Store the average rating count in session
+ $_SESSION['averageRating'] = $avgrating;
- // Display the average rating count
-// echo "Average Rating: " . $formattedAverageRating;
-// echo "Average Rating: " . $avresult;
- } else {
- echo "No details found for the destination.";
- }
+ // Debug Display the average rating count
+ //echo "Average Rating: " . $formattedAverageRating;
+ //echo "Average Rating: " . $totalrating;
+
+
+ } else {
+ echo "No details found for the destination.";
+ }
- }
+}
// Display the Total rating with percentage count
$totratingCounts = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0);
@@ -70,7 +70,7 @@
echo "Error executing query: " . $conn->error;
}
-// Output the counts and percentages
+// Debug Output the counts and percentages
/*
for ($i = 1; $i <= 5; $i++) {
echo "Count of " . $i . "-star: " . $totratingCounts[$i] . "<br>";
@@ -80,23 +80,5 @@
// Close the connection
mysqli_close($conn);
-// debug test data
-/*
-// Fetch all the ratings
-$avquery = "SELECT user_rating FROM review";
-$avresult = mysqli_query($conn, $avquery);
-$ratings = array();
-if (mysqli_num_rows($avresult) > 0) {
- while ($row = mysqli_fetch_assoc($avresult)) {
- $ratings[] = $row['user_rating'];
- }
-}
-$totalrating = count($ratings);
-// Calculate the average rating count
-$countRating = count($ratings) > 0 ? array_sum($ratings) / count($ratings) : 0;
-$avgrating = number_format($countRating, 1);
-
-// Display the average rating count
-//echo "Average Rating: " . $avgrating;*/
?>