<?php

require "conn.php";

date_default_timezone_set("Asia/Kuala_Lumpur");
$tarikh = date("Y-m-d H:i:s");

if (isset($_POST['paid'])) {

    $wd = $_POST['wd'];

    if (!empty($wd)) {

        foreach($_POST['wd'] as $id){
                    $sql = "UPDATE `withdraw` SET `status` = 1, paydate='".$tarikh."' WHERE status <> 1 AND `id` = ".$id;
                    mysqli_query($con, $sql);

        }

    }

header('Location: withdrawal.php');


}

if (isset($_POST['unpaid'])) {

    $wd = $_POST['wd'];

    if (!empty($wd)) {

        foreach($_POST['wd'] as $id){
                    $sql = "UPDATE `withdraw` SET `status` = 0, paydate='0000-00-00 00:00:00' WHERE `id` = ".$id;
                    mysqli_query($con, $sql);

        }
    }

header('Location: withdrawal.php');
}