<?php
	session_start();
	if($_SESSION['rid'])
	{
		//$userid= $_SESSION['rid'];
		$userid=500015;
	}
	else
	{
		header('location:../login.php');
	}
?>
<?php
    include'connection.php';
    include'time.php';
    exit();
    $quGetRet="select * from distributer";
    $reGetRet=mysqli_query($con,$quGetRet);
    while($dataGetRet=mysqli_fetch_array($reGetRet))
    {
        $RetUsrId=$dataGetRet['Userid'];
    
        $TotalTxn=0;
        $quGetBal="select * from wallet where Userid='$RetUsrId' and Id>='234084'";
        $reGetBal=mysqli_query($con,$quGetBal);
        $rowsNo=mysqli_num_rows($reGetBal);
        while($dataGetBal=mysqli_fetch_array($reGetBal))
        {
            $txn=$dataGetBal['Txn'];
            $TotalTxn=$TotalTxn+$txn;
        }
        $quinsert="insert into RetBal(Userid,Walletid,Balance) values('$RetUsrId','234084','$TotalTxn')";
        if(mysqli_query($con,$quinsert))
        {
            echo "success";
        }
        
        
        if($rowsNo>=10000)
        {
            
        }
    }
    
?>