-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtotal.php
More file actions
98 lines (85 loc) · 2.53 KB
/
total.php
File metadata and controls
98 lines (85 loc) · 2.53 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
90
91
92
93
94
95
96
97
98
<?php
include 'db.php';
// Check if session is not already started
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
$user_id = $_SESSION['user_id'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Total Income & Expense</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
font-family: Arial, sans-serif;
background: linear-gradient(to right, green, lightseagreen);
color: white;
}
.summary-box {
background: teal;
padding: 20px;
border-radius: 12px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
width: 350px;
text-align: center;
backdrop-filter: blur(10px);
}
h2 {
margin-bottom: 15px;
color: #fff;
}
p {
font-size: 18px;
margin: 10px 0;
}
.income {
color: lime;
font-weight: bold;
}
.expense {
color: violet;
font-weight: bold;
}
.balance {
color: #ffeb3b;
font-weight: bold;
}
.button {
display: inline-block;
padding: 10px 15px;
margin-top: 15px;
text-decoration: none;
color: white;
background: #333;
border-radius: 6px;
}
.button:hover {
background: #222;
}
</style>
</head>
<body>
<?php
$incomeTotal = $conn->query("SELECT SUM(amount) AS total_income FROM income WHERE user_id='$user_id'")->fetch_assoc()['total_income'] ?? 0;
$expenseTotal = $conn->query("SELECT SUM(amount) AS total_expense FROM expenses WHERE user_id='$user_id'")->fetch_assoc()['total_expense'] ?? 0;
$balance = $incomeTotal - $expenseTotal;
?>
<div class="summary-box">
<h2>💵 Total Summary</h2>
<p><strong>Total Income:</strong> <span class="income">৳<?php echo number_format($incomeTotal, 2); ?></span></p>
<p><strong>Total Expense:</strong> <span class="expense">৳<?php echo number_format($expenseTotal, 2); ?></span></p>
<p><strong>Balance:</strong> <span class="balance">৳<?php echo number_format($balance, 2); ?></span></p>
<a href="index.php" class="button">Back to Home</a>
</div>
</body>
</html>