<?php
include("connect.php");

if (isset($_POST['value']) && $_POST['value'] != "") {

	$q = $_POST['value'];
    
	$result = mysql_query("SELECT * FROM staff WHERE staffName = '".$q."'");
	 
	$row = mysql_fetch_array($result);
	
	$result1 = mysql_query("SELECT * FROM epf WHERE typeepf = 'Staff Rate'");
	 
	$row1 = mysql_fetch_array($result1);
	
	$result2 = mysql_query("SELECT * FROM epf WHERE typeepf = 'Owner Rate'");
	 
	$row2 = mysql_fetch_array($result2);
	
	$result3 = mysql_query("SELECT * FROM staffleave WHERE staffName = '".$q."'&&leaveUpdate=''&&leaveApprove='Yes'");
	
	$num_results = mysql_num_rows($result3);
	
	for($i=0;$i<$num_results;$i++){
	$row3 = mysql_fetch_array($result3);
	
	$c = $row3['Nopayleave'];
	$totalLeave = $totalLeave + $c;
	
	}
	
	$salary = $row['staffSalary'];
	$hour = $row['staffHour'];
	$PCB = $row['staffPCB'];
	$staffPayLeave = $row['staffPayLeave'];
	$staffrate = $row1['epfvalue'];
	$ownerrate = $row2['epfvalue'];
	//$totalLeave = $row3['totalLeave'];
	
	//$arr = array(
    //'z'=>array(
    //    'age'=>33,
    //    'worktime'=>10
    //),
	//);

	$arr = array(
    $q =>array(
        'salary'=>$salary,
		'hour'=>$hour,
		'PCB'=>$PCB,
		'staffPayLeave'=>$staffPayLeave,
		'totalLeave'=>$totalLeave,
    ),
	);
	
	
    foreach($arr as $k=>$v) {
        
        if ($k == trim($q)) {
			echo $v['salary'] . '|'. $v['hour'] . '|' . $v['PCB'] . '|' . $v['staffPayLeave'] . '|' . $v['totalLeave'];
			//echo $v['ISBN'] . '|'. $v['price'] . '|' . $v['bad'];
        } 
    }
}
?>