Anyway I can combine these statements into one. The first sql sums all received quantity and the second statement sums all invoice totals, then the last statement is the basic math to get the average cost.
SELECT receive.quantity, sum( receive.quantity ) AS 'receivedsum'
FROM receive
WHERE receive.equipmentid = 453
GROUP BY receive.equipmentid";
SELECT receive.totalcost, sum( receive.totalcost ) AS 'totalsum'
FROM receive
WHERE receive.equipmentid = 453
GROUP BY receive.equipmentid";
$average=totalsum/receivedsum;