-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeedback_list.php
More file actions
42 lines (39 loc) · 1.81 KB
/
feedback_list.php
File metadata and controls
42 lines (39 loc) · 1.81 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
<?php
include 'includes/db.php';
// Fetch latest feedbacks
$sql = "SELECT f.*, u.profile_photo, u.name AS user_name
FROM feedback f
LEFT JOIN users u ON f.user_id = u.id
ORDER BY f.created_at DESC";
$result = $conn->query($sql);
if ($result && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$photo = !empty($row['profile_photo']) ? $row['profile_photo'] : 'assets/default_user.png';
$name = htmlspecialchars($row['user_name'] ?: $row['name']); // fallback to submitted name
$comment = htmlspecialchars($row['comment']);
$rating = (int)$row['rating'];
$time = date('d M Y, H:i', strtotime($row['created_at']));
$screenshot = !empty($row['screenshot']) ? "<img src='{$row['screenshot']}' class='mt-2 rounded-lg max-w-full border border-gray-300'>" : '';
echo "
<div class='bg-gray-100 dark:bg-gray-800 p-4 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 flex space-x-4'>
<img src='{$photo}' class='w-12 h-12 rounded-full object-cover border-2 border-indigo-500'>
<div class='flex-1'>
<div class='flex justify-between items-center mb-1'>
<span class='font-semibold text-gray-800 dark:text-gray-200'>{$name}</span>
<span class='text-gray-500 text-sm'>{$time}</span>
</div>
<div class='flex space-x-1 text-amber-400 mb-2'>";
for ($i = 1; $i <= 5; $i++) {
if ($i <= $rating) echo "<i class='bx bxs-star'></i>";
else echo "<i class='bx bxs-star text-gray-300 dark:text-gray-600'></i>";
}
echo "</div>
<p class='text-gray-700 dark:text-gray-300'>{$comment}</p>
{$screenshot}
</div>
</div>
";
}
} else {
echo "<p class='text-gray-500 italic'>No feedback yet. Be the first to submit!</p>";
}