All pastes #632016 Raw Edit

Miscellany

public text v1 · immutable
#632016 ·published 2007-07-24 15:08 UTC
rendered paste body
$uisocount=1;
$uipocount=1;


$SOPartsUsed = "SELECT ItemID, QuantityInvoiced FROM dbo.tblSOPartsUsed";
$SODATA = mssql_query($SOPartsUsed);



while ($row = mssql_fetch_array($SODATA)){
	
	for ($a=0;$a<$uisocount;$a++){
		if ($row['ItemID'] != $uniqueSO[$a]){
		$uniqueSO[$uisocount+1]=$row['ItemID'];
		$uniqueSO[$uisocount+1]['quantity']=$row['QuantityInvoiced'];
		$uisocount++;
		}
		elseif($row['ItemID'] == $uniqueSO[$a]){
		$uniqueSO[$a]['quantity'] = $uniqueSO[$a]['quantity'] + $row['QuantityInvoiced'];
		}
		
	}
}


$POReceived = "SELECT ItemID, QuantityReceived FROM dbo.tblPOReceipts";
$PODATA = mssql_query($POReceived);


while ($row = mssql_fetch_array($PODATA)){
	for ($b=0;$b<$uipocount;$b++){
		if ($row['ItemID'] != $uniquePO[$b]){
		$uniquePO[$uipocount+1]=$row['ItemID'];
		$uniquePO[$uipocount+1]['quantity']=$row['QuantityReceived'];
		$uipocount++;
		}
		elseif($row['ItemID'] == $uniquePO[$b]){
		$uniquePO[$b]['quantity'] = $uniquePO[$b]['quantity'] + $row['QuantityReceived'];
		}
		
	}
}

$pocount = count($uniquePO);
$socount = count($uniqueSO);

for ($x=0;$x<$pocount;$x++){
	for ($y=0;$y<$socount;$y++){
		if ($uniqueSO[$x]==$uniquePO[$y]){
		echo "{$uniquePO[$y]} - {$uniquePO[$y]['quantity']} - {$uniquePO[$x]['quantity']}";
		}
	}
}