-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
89 lines (77 loc) · 2.74 KB
/
dashboard.php
File metadata and controls
89 lines (77 loc) · 2.74 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
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);
$servername = "sql111.infinityfree.com";
$username = "if0_39103916";
$password = 'Mu5abM51';
$dbname = "if0_39103916_zenlog";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if (!isset($_SESSION['user_id'])) {
die("User not logged in.");
}
$user_id = $_SESSION['user_id'];
// Fetch mood data for the user
$sql = "SELECT mood_level, mood_comment, mood_trigger, date FROM mood_data WHERE user_id = ? ORDER BY date DESC";
$stmt = $conn->prepare($sql);
if ($stmt === false) {
die("Prepare failed: " . $conn->error);
}
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();
$mood_data = [];
while ($row = $result->fetch_assoc()) {
$mood_data[] = $row;
}
$stmt->close();
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Dashboard - ZenLog</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container mt-5">
<h1 class="text-center">Your Mood Data</h1>
<div class="row">
<div class="col-md-12">
<table class="table table-striped">
<thead>
<tr>
<th>Date</th>
<th>Mood Level</th>
<th>Comments</th>
<th>Trigger</th>
</tr>
</thead>
<tbody>
<?php foreach ($mood_data as $data): ?>
<tr>
<td><?php echo htmlspecialchars($data['date']); ?></td>
<td><?php echo htmlspecialchars($data['mood_level']); ?></td>
<td><?php echo htmlspecialchars($data['mood_comment']); ?></td>
<td><?php echo htmlspecialchars($data['mood_trigger']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
document.body.classList.add("fade-in");
});
</script>
</body>
</html>