Can't believe what I'm trying to do is so difficult or maybe I'm going about all wrong, which is certainly a possibility. I was able to add the Description field, however when I create the table for output it prints as the part number so my table comes out twice as long as before (one row for each part number and one for each part number description). Here is the modified code with the array_push() added as well as the code I use to loop through and output the array.
$totals = array(); //create array to hold totals
$deptScrap = 0; //total scrap for department
//$partScrap = 0; //total scrap for partnumber
while ($row = mysql_fetch_array($dbResult, MYSQL_ASSOC)) {
if(!isset($totals[$row['Part']])) { //search array to see if current part number is in it
$totals[$row['Part']] = array(); //create array to store part info
array_push($totals[$row['Description']]); //Add Description field to array
}
if(!isset($totals[$row['Part']][$row['Type']])) { //search array to see if current defect type is associated with this part number
$totals[$row['Part']][$row['Type']] = 0; //create running total of defects per defect type and set to zero
$totals[$row['Part']][$row['Type']] += $row['Defects'];
$deptScrap += $row['Defects']; //add to running total of total defects for department
} else {
$totals[$row['Part']][$row['Type']] += $row['Defects']; //Add the number of defects per defect type to running total
$deptScrap += $row['Defects']; //add to running total of total defects for department
}
}
print "<TABLE cellpadding='0' cellspacing='0' border='0'>";
print "<TR><TH>Part #</TH><TH>Qty</TH><TH>Defect Detail</TH></TR>";
uasort($totals, "part_sort");
foreach($totals as $Part => $partNum) {
print "<TR><TD>";
print " {$Part} ";
print "</TD><TD>";
$defectCount = 0; //zero counter for total part scrap before looping through scrap
uasort($partNum, "sort_defects");
foreach($partNum as $Defect => $scrap) {
$defectCount += $scrap; //create running total for this part #'s scrap
}
print $defectCount; //print running total
print "</TD><TD>";
foreach($partNum as $Defect => $scrap){
print "[{$Defect}={$scrap}] ";
}
print "</TD></TR>"; //Close row
}
print "</TABLE>";