-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
166 lines (138 loc) · 6.49 KB
/
index.php
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<script src="https://kit.fontawesome.com/1e938fdd74.js" crossorigin="anonymous"></script>
<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=Poppins&display=swap" rel="stylesheet">
<title>Expense Tracker</title>
</head>
<body>
<div class="container">
<div class="title">
<h1>Expense Tracker</h1>
<div class="balance">
<h4>Your Balance</h4>
<?php
include "inc/db.inc.php";
$query = "select sum(price) from itemstb";
$res = mysqli_query($conn, $query);
if(mysqli_num_rows($res) > 0){
while($data = mysqli_fetch_assoc($res)){
echo '<h1 id="balanceAmount">$' . $data['sum(price)'] . '</span>';
}
}else{
echo '<h1 id="balanceAmount">$0</span>';
}
$sql = "select price, sum(price) from itemstb where price > 0";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
echo '<div class="inc-exp-container">
<div class="inc">
<h4 class="black">Income</h4>
<p id="money-plus" class="money plus">$' . $row['sum(price)'] . '</p>
</div>';
}
}else{
echo '<h1 id="balanceAmount">$0</span>';
echo '<div class="inc-exp-container">
<div class="inc">
<h4 class="black">Income</h4>
<p id="money-plus" class="money plus">$0</p>
</div>';
}
$sql = "select sum(price) from itemstb where price < 0";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
echo '
<div class="bal">
<h4 class="black">Expense</h4>
<p id="money-minus" class="money minus">$' . $row['sum(price)'] . '</p>
</div>
</div>';
}
}else{
echo '<div class="bal">
<h4 class="black">Expense</h4>
<p id="money-minus" class="money minus">$</p>
</div>
</div>';
}
?>
</div>
</div>
<div class="history">
<h4>History</h4>
<hr>
<?php
include "inc/db.inc.php";
$sql = "select * from itemstb where price > 0";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
echo "<div class='items-container'>
<div class='item'>
<div class='align-content'>
<div class='addItems'>". $row['item_name'] ."</div>
</div>
</div>
<div class='itemCost'>
<p>$" . $row['price'] . "</p>
</div>
<a href='inc/deleteData.inc.php?id=" . $row['id'] . "'><i class='fa-solid fa-square-xmark mark'></i></a>
</div>";
}
}else{
echo "<div class='items-container'>
<div class='item'>
<div class='align-content'>
<div class='addItems'>No Result Found!</div>
</div>
</div>
<div class='itemCost NA'>
<p>N/A</p>
</div>
</div>";
}
$sql = "select * from itemstb where price < 0";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
echo "<div class='items-container'>
<div class='item'>
<div class='align-content'>
<div class='addItems'>". $row['item_name'] ."</div>
</div>
</div>
<div class='itemCost exp'>
<p>$" . $row['price'] . "</p>
</div>
<a href='inc/deleteData.inc.php?id=" . $row['id'] . "'><i class='fa-solid fa-square-xmark mark'></i></a>
</div>";
}
}
?>
</div>
<div class="addTransaction">
<h4>Add Transaction</h4>
<hr>
<div class="text">
<p>Text</p>
<form action="inc/dataEntry.inc.php" method="POST">
<input type="text" class="itemName" name="itemName" placeholder="Enter Text" value="" required>
<p class="amount">Amount</p>
<p>(negative - expense,positive - income)</p>
<input type="number" class="itemAmount" name="itemPrice" placeholder="Enter Amount" step="any" required>
<input type="submit" class="submit" name="submit" value="Add transaction"></input>
</form>
</div>
</div>
</div>
</body>
</html>