vendredi 19 août 2016

If else double check

I have the following code:

$znalazl = false;
while($row = mysql_fetch_assoc($result))
{
    if(strtolower($message) == $row['question'])
    {
        msg('Znalazlem');
    } elseif(!$znalazl)
    {
        dodaj(strtolower($message), '', 1);
        msg('Nie znalazlem');
        $znalazl = true;
    }
}

Result: first run - "Nie znalazlem", second run - "Nie znalazlem", "Znalazlem". Why in second run i have "nie znalazlem" and "znalazlem"? I would like to have only "znalazlem" message. Function dodaj(); works correcly. Please help.

Aucun commentaire:

Enregistrer un commentaire