所以我在 MySQL 数据库中有以下数据
id date type source particulars amount user
1 8/23/19 debit General load payment 500.00 1
2 8/24/19 credit Loan record loan 7,000.00 1
3 8/22/19 debit General grocery 800.00 1
4 8/25/19 credit General record salary 10,000.00 1
5 8/10/19 credit General other income 20,000.00 1
有了这些数据,我想实现以下目标:
按日、月和年对项目进行排序和分组
按用户过滤数据
创建余额表 - 逻辑是当类型为贷方时,则执行加法,如果为借方,则执行减法
我只能执行我拥有的前两个任务,但似乎我无法连续执行数学运算。
我希望我的输出是这样的:
INCOME STATEMENT
Period covered: August 2019
Name: 1
8/25/19 credit General record salary +10,000.00
8/22/19 debit General grocery - 800.00
8/23/19 debit General load payment - 500.00
8/24/19 credit Loan record loan + 7,000.00
8/25/19 credit General record salary +10,000.00
CASH ON HAND 25,700.00
使用 if-else 条件,我只能做到这一点:
Period covered: August 2019
Name: 1
8/25/19 credit General record salary +10,000.00
8/22/19 debit General grocery - 800.00
8/23/19 debit General load payment - 500.00
8/24/19 credit Loan record loan + 7,000.00
8/25/19 credit General record salary +10,000.00
到目前为止我尝试过的代码。
<table id="myTable" class="table table-bordered table-striped">
<thead>
<tr>
<th>ID</th>
<th>TYPE</th>
<th>SOURCE</th>
<th>PARTICULARS</th>
<th></th>
<th>AMOUNT</th>
</tr>
</thead>
<tbody>
我无法回应手头现金中金额列的总和/差异。
蝴蝶刀刀