<?php
include '../includes/config.php';

if (isset($_POST['update-amount'])) {
    
    echo $gametype =  $_POST['starline_market_one'];
    
    if ($gametype == "starline_market"){
        $game_amount = $_POST['game_amount'];
        $id = $_POST['id'];
        // $dataid = explode(' ', $id);
        $size = sizeof($id);
        for ($i=0; $i < $size; $i++) { 
            $gemAmount = $game_amount[$i];
            $varId = $id[$i];
            $sql = "UPDATE `starLineRate` SET `gameRate`='$gemAmount' WHERE id='$varId'";
            $out = mysqli_query($conn,$sql);        
        }
    
        if($out <= 0) {
           echo '<script>alert("Rate Update Failed");window.location = "../star-line-betting.php";</script>';
        }else{
            echo '<script>alert("Rate Update Successfully");window.location = "../star-line-betting.php";</script>';
        }
    }elseif ($gametype == "starline_market_one"){
        
        $game_amount = $_POST['game_amount'];
        $id = $_POST['id'];
        // $dataid = explode(' ', $id);
        $size = sizeof($id);
        for ($i=0; $i < $size; $i++) { 
            $gemAmount = $game_amount[$i];
            $varId = $id[$i];
            $sql = "UPDATE `starLineRate` SET `gameRate`='$gemAmount' WHERE id='$varId'";
            $out = mysqli_query($conn,$sql);        
        }
    
        if($out <= 0) {
           echo '<script>alert("Rate Update Failed");window.location = "../kolkataff-game-rates.php";</script>';
        }else{
            echo '<script>alert("Rate Update Successfully");window.location = "../kolkataff-game-rates.php";</script>';
        }
        
    }elseif($gametype == "starline_market_two"){
        
        $game_amount = $_POST['game_amount'];
        $id = $_POST['id'];
        // $dataid = explode(' ', $id);
        $size = sizeof($id);
        for ($i=0; $i < $size; $i++) { 
            $gemAmount = $game_amount[$i];
            $varId = $id[$i];
            $sql = "UPDATE `starLineRate` SET `gameRate`='$gemAmount' WHERE id='$varId'";
            $out = mysqli_query($conn,$sql);        
        }
    
        if($out <= 0) {
           echo '<script>alert("Rate Update Failed");window.location = "../mumbaiff-game-rates.php";</script>';
        }else{
            echo '<script>alert("Rate Update Successfully");window.location = "../mumbaiff-game-rates.php";</script>';
        }
        
    }
    
    
    
}else {
    echo '<script>alert("Something went wrong");window.location = "../dashboard.php";</script>';
}

?>