title: Change DIV class with PHP
body: <p>I’m trying to style some DIV’s with CSS. What I want to do is change DIV tag class inside MySql loop using PHP.</p>
  
  <pre><code>&lt;?php
  $result = $mysqli-&gt;query("SELECT * FROM posts ORDER BY id DESC LIMIT 0, 20");
  while($row = mysqli_fetch_array($result))
      {
  ?&gt;
  &lt;div class=” box id1”&gt;&lt;?php echo $row[‘post’];?&gt;&lt;/div&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>So I want to change the class box id1 in this order</p>
  
  <pre><code>box id1
  box id1
  box id2
  box id2
  box id2
  box id2
  box id1
  box id1
  box id2
  box id2
  box id2
  box id2
  So on.  (2 div tags with the class box id1 then 4 with box id2 looping)
  </code></pre>
  
  <p>I tried using rand(1, 2); but this making the numbers comes randomly not for the order I want. Any help will be much appreciated. Thanks in advance.</p>