What I do not do right (or what i'm missing)


//Add while loop below
$an= 2015;
while($an < 2024) {

$an ++;

    if($an= $an + 4){            
        echo "<div class=\"coin\">bis</div>";
        } else{
           echo "<div class=\"coin\">nim</div>";


I want the while loop to show me leap years($an= $an + 4) in

, and all others in


Is this an exercise? i can't find it. What exactly are you trying to achieve?

First of all, i am a bit worried about this:

if($an= $an + 4)

you have a if statement (condition) but rather then checking for a condition (two equal signs) you asign $an a value of $an + 4.

even if you had:

if($an==  $an + 4)

this statement will never be true, $an does never equal $an + 4

shouldn't your if statement be something like:

if ($an % 4 == 0}

if $an module 4 equals zero, it is a leapyear


it is the exercise 3 from LOOPS: WHILE AND DO-WHILE. As a result I want the while loop to show me everi four years with bis the others with nim



    //this looks good 
    $an= 2015;   
         while($an < 2024) {
            $an ++;
            // here we have some mistakes 
            if($an%4 == 0){            
                  echo "<div class=\"coin\">bis</div>";
            } else {
                    echo "<div class=\"coin\">nim</div>";



if you followed the steps i provided in my answer, you would have gotten exactly that output. Why am i writing answers if they are not being read?


OK. It works. Thank you very much


It works thank you once again. )))))))


Thak you. this is what I need.


You can indeed take over dookoo_de answer, it will work, but i wanted you to do most of the thinking, which i hoped teached you a lot. Oh, something i wanted to say, when you add a html element with id/class or any other attribute, it is fine to you use apostrophe (') rather then quotation mark ("), which saves you the trouble of escaping the quotation marks:

echo "<div class='coin'>bis</div>";


Gleb078, Do you speak Romanian? "An" in Romanian translates to "years." :relaxed:


da desigur:) vorbesc romana