Hi Guys!
I want to loop through the below statement. I will have a different $itemid each time and would like the end result to be placed in a new variable. The item ID's will look like 411,211,233,433. Maybe I can place the end variable in an array like such avg[411]=8.02, avg[211]=4.22. Any ideas as how I can approach this??
///GET AVERAGE PRICE
$getall="SELECT receive.quantity, sum( receive.quantity ) AS 'receivedsum'
FROM receive
WHERE receive.equipmentid = $itemid
GROUP BY receive.equipmentid";
$getcostresult=mysql_query($getall, $link);
$getcostline=mysql_fetch_array($getcostresult, MYSQL_ASSOC);
$getall2="SELECT receive.totalcost, sum( receive.totalcost ) AS 'totalsum'
FROM receive
WHERE receive.equipmentid = $itemid
GROUP BY receive.equipmentid";
$getcostresult2=mysql_query($getall2, $link) ;
$getcostline2=mysql_fetch_array($getcostresult2, MYSQL_ASSOC);
$average=$getcostline2[totalsum]/$getcostline[receivedsum];
$average=round($average,2);