samedi 26 juin 2021

Php while loop ends after continue

I have problem with my script. I need send mail when my $sended variable is set on 0, if is set to 1 than i need to ignore this statemant

<?php
while ($result = $pdo->fetch(PDO::FETCH_ASSOC)) {

        if($result['howMany'] == "0") {
          if ($sended == "0") {
            //send mail to admin with info that product was end.
            //this is work fine
            if($mail->send()) {
              //change in my database variable $sended to 1;
              //this is work fine to.
              //if i live it empty, it is work, but if I change $sended to 1, it is not working
            }
          }
          // if variable $result['howMany'] is equal to 0 than i need to end this iteration of while loop.
          continue;
        }

        //rest of script that should work when $result['howMany'] != "0"
}
?>

Problem is when $sended variable is set to 0, continue is ending whole loop not only this one iteration. When $sended == 1, than everything is working just fine. Continue work fine. What do I do wrong? Where's error because i dont see it. Sorry for my english. It is not my native language.

Aucun commentaire:

Enregistrer un commentaire