-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtransaction.php
More file actions
106 lines (91 loc) · 4.22 KB
/
transaction.php
File metadata and controls
106 lines (91 loc) · 4.22 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
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>transaction</title>
<link rel=stylesheet href='assets/navbar.css' type='text/css'>
<link rel=stylesheet href='transaction.css' type='text/css'>
<!-- google font -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter&display=swap" rel="stylesheet">
<!-- script -->
<script src="transaction.js"></script>
</head>
<body>
<span id="navbar">
<?php include 'navbar.php'; ?>
</span>
<div class="content">
<div class="title">
<p id="transaction_title">TRANSACTION<a href="register.php" class="register">+ REGISTER</a></p>
</div>
<br><br>
<div class="transaction_result">
<?php
session_start();
error_reporting(E_ALL);
ini_set("display_errors", 1);
include_once 'dbconfig.php';
$db_name = 'keeping';
mysqli_select_db($conn, $db_name);
$user_id = $_SESSION['username'];
if (isset($_POST['currentMonth'])) {
$currentMonth = $_POST['currentMonth'];
$_SESSION['currentMonth'] = $currentMonth;
} elseif (isset($_SESSION['currentMonth'])) {
$currentMonth = $_SESSION['currentMonth'];
} else {
$currentMonth = date('n');
}
echo "<p>Current Month: " . $currentMonth . "</p>";
?>
<form action="" method="post" class="monthForm" id="monthForm">
<span onclick="changeMonth(-1)">◀</span>
<span id="currentMonth"><?php echo $currentMonth; ?></span>월
<input type="hidden" name="currentMonth" id="hiddenCurrentMonth" value="<?php echo $currentMonth; ?>">
<span onclick="changeMonth(1)">▶</span>
<input type="submit" name="Check" value="Submit">
</form>
<?php
$TransactionResultQuery = "SELECT
CASE DAYOFWEEK(t.date_t)
when '1' then 'Sun'
when '2' then 'Mon'
when '3' then 'Tue'
when '4' then 'Wed'
when '5' then 'Thu'
when '6' then 'Fri'
when '7' then 'Sat'
END AS 요일, MONTH(t.date_t) AS 월, DAY(t.date_t) AS 일, t.deposit_or_withdrawal AS 입출금, t.price AS 가격, t.client AS 거래처, c.category_name AS 카테고리명
FROM transaction t
JOIN category c ON t.t_category_id = c.category_id
where t.t_user_id = '$user_id'
AND MONTH(t.date_t) = '$currentMonth'
ORDER BY DAY(t.date_t)";
$result = $conn->query($TransactionResultQuery);
if ($result && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<div class='transaction-info'>";
echo "<p>";
echo $row['일'] . " ";
echo $row['요일'] . " <br>";
echo "<hr>";
echo $row['입출금'] . " ";
echo $row['가격'] . " ₩ ";
echo $row['거래처'] . " ";
echo $row['카테고리명'] . " ";
echo "<br><br>";
echo "------------------------------------";
echo "</p>";
}
}
else {
echo "NULL.";
}
?>
</div>
</div>
</body>
</html>