I have the need to generate a PHP page that displays all details stored in an array (from a MySQL request) in a way that shows a count/summary of each similar line item.
Here is an example dataset collected from an SQL query (it has been structure to ORDER BY Workgroup, ProductCode):
+----+-------------+-------------+-----------+-----------+
| ID | ProductCode | Description | Workgroup | Status |
+----+-------------+-------------+-----------+-----------+
| 2 | A123 | Coke | Finance | Ordered |
| 4 | A123 | Coke | Finance | Rejected |
| 1 | A123 | Coke | Finance | Rejected |
| 6 | B111 | Pepsi | Finance | Ordered |
| 5 | B111 | Pepsi | Finance | Rejected |
| 8 | B111 | Pepsi | Finance | Rejected |
| 10 | B112 | Fanta | Finance | Ordered |
| 42 | A123 | Coke | Management| Ordered |
| 16 | A123 | Coke | Management| Ordered |
| 11 | B112 | Fanta | Management| Rejected |
+----+-------------+-------------+-----------+-----------+
These details have been stored in a PHP array as follows:
Array
(
[0] => Array
(
[ID] => 2
[ProductCode] => A123
[Description] => Coke
[Workgroup] => Finance
[Status] => Ordered
)
[1] => Array
(
[ID] => 4
[ProductCode] => A123
[Description] => Coke
[Workgroup] => Finance
[Status] => Rejected
)
...etc
)
What I require is to spit the data out in multiple tables separated by WorkGroup, with a single summary line per Product with each individual line item listed beneath (it doesn't strictly need to be a html table, just some HTML construct that is able to represent the line-items)
From the 10 example entries I've shown, it would need to output the following:
+--------------------------------------------------------+
| FINANCE TEAM |
+----+-------------+-------------+-----------+-----------+
| Coke Total: 3 Ordered: 1 Rejected: 2 |
+----+-------------+-------------+-----------+-----------+
| 2 | A123 | Coke | Finance | Ordered |
| 4 | A123 | Coke | Finance | Rejected |
| 1 | A123 | Coke | Finance | Rejected |
+----+-------------+-------------+-----------+-----------+
| Pepsi Total: 3 Ordered: 1 Rejected: 2 |
+----+-------------+-------------+-----------+-----------+
| 6 | B111 | Pepsi | Finance | Ordered |
| 5 | B111 | Pepsi | Finance | Rejected |
| 8 | B111 | Pepsi | Finance | Rejected |
+----+-------------+-------------+-----------+-----------+
| Fanta Total: 1 Ordered: 1 Rejected: 0 |
+----+-------------+-------------+-----------+-----------+
| 10 | B112 | Fanta | Finance | Ordered |
+----+-------------+-------------+-----------+-----------+
+--------------------------------------------------------+
| MANAGEMENT TEAM |
+----+-------------+-------------+-----------+-----------+
| Coke Total: 2 Ordered: 2 Rejected: 0 |
+----+-------------+-------------+-----------+-----------+
| 42 | A123 | Coke | Management| Ordered |
| 16 | A123 | Coke | Management| Ordered |
+----+-------------+-------------+-----------+-----------+
| Fanta Total: 1 Ordered: 0 Rejected: 1 |
+----+-------------+-------------+-----------+-----------+
| 11 | B112 | Fanta | Management| Rejected |
+----+-------------+-------------+-----------+-----------+
I can elaborate further if what I require isn't clear enough.
ANY help would be GREATLY appreciated.
Thanks in advance.