<?php 
ob_start();
session_start();

if($_SESSION['name'] == '')
 {
     header("location:index.php");
 }
include('includes/config.php');


 $id=$_GET['ID'];
 
$useridQuery=mysqli_query($com,"select `userid`,`amount` from `withdrawal` where `id`='".$id."'");
$userResult=mysqli_fetch_array($useridQuery);
$userid=$userResult['userid'];
$amount=$userResult['amount'];

$sqlwallet = mysqli_query($com,"select * from wallet where userid='$userid'");
$datawallet = mysqli_fetch_array($sqlwallet);
$walletbalance = $datawallet['amount'];
$finalbalanceCredit=$walletbalance+$amount;	
$sqlwallet= mysqli_query($com,"UPDATE `wallet` SET `amount` = '$finalbalanceCredit' WHERE `userid`= '$userid'");

$famount = ($amount * 15)/100;

$sqlliq = mysqli_query($com,"select * from liquid_fund where userid='$userid'");
$liqwallet = mysqli_fetch_array($sqlliq);
$liqbalance = $liqwallet['amount'];
$finallq=$liqbalance-$famount;	
$sqlliqupdate= mysqli_query($com,"UPDATE `liquid_fund` SET `amount` = '$finallq' WHERE `userid`= '$userid'");

 $sql="delete from withdrawal WHERE id='$id'";
$query=mysqli_query($com,$sql);

echo "<script>
alert('Delete Sucessfully');
window.location.href='withrequest.php';
</script>";

?>