<?php 
$login=mysql_connect('localhost', 'wauhaha_karaoke', 'cross123','wauhaha_karaoke');
	
mysql_selectDB("wauhaha_karaoke",$login);	

$no = $_GET['no'];

$result=mysql_query("select * from lreason where no='$no'");
$r=mysql_fetch_array($result);

$id = $r['id'];
$sd = $r['sd'];
$ed = $r['ed'];
$sh = $r['sh'];
$eh = $r['eh'];
$h = $r['h'];
$re = $r['r'];
$Date = $r['Date'];
$lr = $r['lr'];


$result2= mysql_query("select * from leave2 where id='$id'");
$r2 = mysql_fetch_array($result2);
$l = $r2['l'];

$lr2 = $l + $h;

$query = mysql_query("Update leave2 set l='$lr2' where id='$id'");
$query2 =mysql_query("delete from lreason where no='$no'");

if(($query)&&($query2)){

			echo "<script language='javascript'>alert('Deny Success.')</script>";
			echo "<script language='javascript'>window.location='leave.php?id=$id'</script>";

}else 		echo "<script language='javascript'>alert('Deny Fail.')</script>";
			echo "<script language='javascript'>window.location='leave.php?id=$id'</script>";




?>