PHP - Update player level

0

Hello, I'm creating a system of levels But, the level does update depending on the refresh of the page. example: Exp max is 100% which is = a 100.

If I add 1000 exp to the user account, it uploads the level to the next one, but in refresh, which will take a long time until it stops having 1000 exp.

The code is

        //update level and exp
    $playert_exp = selectplayerexp($db);
    $limit_exp = 100;


    if($player_exp >= $limit_exp) {

        $levelup = (int) ($player_exp / $limit_exp);
        $withdraw = (int) (??????????????);
        update_Level($con, $widthdraw);

        if($player_level != $limit_level) {                
            echo "<script>alert('Boa! Atingiu o Nível $player_level_total.');</script>";
        }              
    }

My goal is to ... claculate the entire exp saved in DB $ player_exp, make the sum for example 100exp = 1lvl, 1000 = 10 lvls.

I was thinking of a foreach, but I can not ...

Now I need something to finish, since I already have the calculation to give the appropriate level according to EXP, now I need to remove this EXP, example

Se o utilizador tiver 1050 de EXP, o calculo deverá retirar todos os valores iguais a 100, o que significa que retira os 1000 e deixa os 50.

I'm standing here ..:

 $withdraw = (int) (??????????????);
    
asked by anonymous 07.09.2018 / 15:37

0 answers