-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_feedback.php
More file actions
40 lines (34 loc) · 1.01 KB
/
get_feedback.php
File metadata and controls
40 lines (34 loc) · 1.01 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
<?php
require_once 'config.php';
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$limit = 5;
$offset = ($page - 1) * $limit;
$totalResult = $conn->query("SELECT COUNT(*) as total FROM feedback");
$totalRow = $totalResult->fetch_assoc();
$total_feedback = $totalRow['total'];
$query = "
SELECT f.*, b.full_name
FROM feedback f
INNER JOIN bookings b ON f.booking_id = b.booking_id
ORDER BY f.submitted_at DESC
LIMIT $limit OFFSET $offset
";
$result = $conn->query($query);
$feedback = [];
while ($row = $result->fetch_assoc()) {
$feedback[] = [
"booking_id" => $row["booking_id"],
"full_name" => $row["full_name"], // NOW it will display correctly
"service_name" => $row["service_name"],
"rating" => $row["rating"],
"comment" => $row["comment"],
"submitted_at" => $row["submitted_at"]
];
}
echo json_encode([
"status" => "success",
"feedback" => $feedback,
"total_feedback" => $total_feedback,
"current_page" => $page
]);
?>