<?php
include "../../inc/inc.koneksi.php";

$kode	= $_POST['kode'];
$kodetk = $_POST['kodetk'];
$jumlahasl= $_POST['jumlahasl'];

$text	= "SELECT * FROM jurpsb WHERE kode_ps='$kode' AND kode_tk='$kodetk'";
$sql 	= mysql_query($text);
$row	= mysql_num_rows($sql);

if ($row>0){
	$total=0;
	while ($r=mysql_fetch_array($sql)){		
		$total=$total+$r[jumlah];
	}
	$selisih = $total-$jumlahasl;
	$data['total']	= $total;
	$data['selisih']= $selisih;
	echo json_encode($data);
}else{	
	$data['total']	= 0;
	$data['selisih'] = 0-$jumlahasl;
	echo json_encode($data);
}
?>
