FårHäst
FårHäst

Reputation: 15

Unintentional for-loop in php

This code keeps creating col-sm-2 with offset-2 and I have no idea why

   for($rum1 = 1; $rum1 <= 25; $rum1++){

        if($rum1 = 1 || $rum = 6 || $rum = 11 || $rum = 16 || $rum = 21){
            echo("<div class='col-sm-2 col-sm-offset-1'><p>12312324341324</p></div>");
        }

        else{
            echo("<div class='col-sm-2'><p>12312324341324</p></div>");
        }

    }

As said it keeps creating divs, what I want it to do is to create 25 divs, with the first ones in every row being with offeset 2.

Upvotes: 1

Views: 16

Answers (1)

Aganju
Aganju

Reputation: 6395

In the if statement, you are assigning five different values to $rum, the last one being 21. So it never makes it over 25.

You probably wanted to compare instead of assigning, use == for that.

Upvotes: 1

Related Questions