I have long arrays (could be hundreds) from $_POST and need to summarize the qty.
Below is the $_POST result:
array(5) {
["Batch_No"]=>
array(3) {
[0]=>
string(7) "AAAV343"
[1]=>
string(7) "AAAV343"
[2]=>
string(7) "AAAV347"
}
["Expire"]=>
array(3) {
[0]=>
string(0) ""
[1]=>
string(0) ""
[2]=>
string(0) ""
}
["Prod_ID"]=>
array(3) {
[0]=>
string(5) "00041"
[1]=>
string(5) "00041"
[2]=>
string(5) "00041"
}
["zID_Line"]=>
array(3) {
[0]=>
string(2) "17"
[1]=>
string(2) "17"
[2]=>
string(2) "17"
}
["Qty"]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "1"
[2]=>
string(1) "1"
}
}
I need to summarize the array using Batch_No and Prod_ID, so that the result would be become like this:
array(5) {
["Batch_No"]=>
array(2) {
[0]=>
string(7) "AAAV343"
[1]=>
string(7) "AAAV347"
}
["Expire"]=>
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
["Prod_ID"]=>
array(2) {
[0]=>
string(5) "00041"
[1]=>
string(5) "00041"
}
["zID_Line"]=>
array(2) {
[0]=>
string(2) "17"
[1]=>
string(2) "17"
}
["Qty"]=>
array(2) {
[0]=>
string(1) "2"
[1]=>
string(1) "1"
}
}
The Qty is basically the TOTAL of each array which has identical Batch_No AND Prod_ID.
Been trying to explore existing topics, but cannot resolve the issues due to those two keys.
GROUP BY Prod_ID, Batch_NoandSUM(Qty_SPTB) AS Qty_Total, issue solved! Thanks everyone.