Here's my code so far....
///get order details
$getpo2= "SELECT * from podetails WHERE ponum = '$ponum'";
$getrow2= mysql_query($getpo2) or die(ErrorDB($realname));
while($line2= mysql_fetch_array($getrow2, MYSQL_ASSOC)){
$getreceive2="select poreceive.quantity, sum(poreceive.quantity) as 'receivedsum2'
from poreceive
where podetailid='$line2[id]'
group by poreceive.podetailid";
$getreceiveresult2=mysql_query($getreceive2, $link) ;
$getreceiveline2=mysql_fetch_array($getreceiveresult2, MYSQL_ASSOC);
if ( $line2[quantity]!==$getreceiveline2[receivedsum2]){
break; }
else
if($line2[quantity]==$getreceiveline2[receivedsum2]){
$status="Closed";
echo $status;}
}