レポート要件に従ってレコードを取得するこの請求テーブルがあります。
私が得る配列は次のようなものです:
Array(
[0] => stdClass Object
(
[bid] => 3
[uid] => 2
[total_inc] => 100
[total_exp] => 55
[mon] => 1
[year] => 2012
[mstdatereg] => 2012-03-14
)
[1] => stdClass Object
(
[bid] => 2
[uid] => 3
[total_inc] => 85
[total_exp] => 45
[mon] => 1
[year] => 2012
[mstdatereg] => 2012-03-14
)
[2] => stdClass Object
(
[bid] => 1
[uid] => 8
[total_inc] => 130
[total_exp] => 75
[mon] => 1
[year] => 2012
[mstdatereg] => 2012-03-14
)
[3] => stdClass Object
(
[bid] => 5
[uid] => 25
[total_inc] => 130
[total_exp] => 65
[mon] => 2
[year] => 2012
[mstdatereg] => 2012-03-14
)
[4] => stdClass Object
(
[bid] => 4
[uid] => 27
[total_inc] => 75
[total_exp] => 50
[mon] => 2
[year] => 2012
[mstdatereg] => 2012-03-14
)
[5] => stdClass Object
(
[bid] => 10
[uid] => 3
[total_inc] => 180
[total_exp] => 100
[mon] => 3
[year] => 2012
[mstdatereg] => 2012-04-05
)
[6] => stdClass Object
(
[bid] => 6
[uid] => 12
[total_inc] => 60
[total_exp] => 35
[mon] => 3
[year] => 2012
[mstdatereg] => 2012-03-14
)
[7] => stdClass Object
(
[bid] => 7
[uid] => 22
[total_inc] => 160
[total_exp] => 90
[mon] => 3
[year] => 2012
[mstdatereg] => 2012-03-14
)
[8] => stdClass Object
(
[bid] => 9
[uid] => 3
[total_inc] => 115
[total_exp] => 70
[mon] => 4
[year] => 2012
[mstdatereg] => 2012-03-16
)
)
ループを通じて行ったことは、次のような結果です。
January, 2012
==========
Income Expense
2 100 55
3 85 45
8 130 75
---------------------------------
Total 315 175
February, 2012
===========
Income Expense
25 130 65
27 75 50
---------------------------------
Total 205 115
March, 2012
Income Expense
3 180 100
12 60 35
22 160 90
---------------------------------
Total 400 225
April, 2012
Income Expense
3 115 70
---------------------------------
Total 115 70
Net Total Income: 1035
Net Total Expense: 585code here
しかし、私が欲しいのは
Sr.No Member 1, 2012 2, 2012 3, 2012 4, 2012 Total
Inc|Exp Inc|Exp Inc|Exp Inc|Exp Inc|Exp
=======================================================================
1 2 100|55 100|55
2 3 85|45 180|100 115|70 380|215
3 8 130|75 130|75
4 25 130|65 130|65
5 27 75|50 75|50
6 12 60|35 60|35
7 22 160|90 160|90
=======================================================================
Total 315|175 205|115 400|225 115|70 1035|585
投稿する前に、そのような問題を検索したところ、これが見つかりました: Building a "crosstab" or "pivot" table from an array in php
私は自分の要件に従ってそれを機能させようとしましたが、そうしませんでした。
何日も試しています。どんな助けでも大歓迎です。