vendredi 12 mars 2021

How to determine every 100 item in a while loop php?

I'm currently learning php and I'm struggling with this:

"For every 100 ordered products in a category, 2% will be deducted:"

This is my code:

$gesA = 309; (The amount of product)

$gesN = 1011.08; (The full price of product)

$i = 1;

            while($i) 
            {
                if($gesA % 100 == 0)
                {
                    echo $gesN;
                    echo "<br>";
                    $gesN = $gesN / 0.2;
                }
                
                $i++;
                $gesN++;
            }
            
            echo $gesN;

Yet, I can't figure it out. Could someone help me?

Aucun commentaire:

Enregistrer un commentaire