title: How to identify if it is odd or even and add class?
body: <p>I have set-up a news page which retrieves news from MYSQL news table.</p>
  
  <p>I am trying to identify if the news column is odd or even, so if the news columns is odd or even it will add a class to the div element.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>&lt;?php
  $cat = $_GET['cat'];
  $date = $_GET['date'];
  
  if ($date !="") {
      $date = explode('-', $date);
      $year = $date[1];
      $month = $date[0];
      $month = date("m", strtotime($month));
      $sql = "SELECT * FROM news WHERE year(newsDate) = '$year' AND month(newsDate) = '$month' AND newsState = 1 ORDER BY newsDate DESC";
  } else {
      $sql = "SELECT * FROM news WHERE newsState = 1 ORDER BY newsDate DESC";
  }
  
  $result = $conn-&gt;query($sql);
  $rows = $result-&gt;num_rows;
  
  $pager = new PS_Pagination($conn, $sql, 5, 10, null);
  
  $rs = $pager-&gt;paginate();
  
  $num = $rs-&gt;num_rows;
  
  if($num &gt;= 1 ){  
  while($row = $rs-&gt;fetch_assoc()){
  ?&gt;
   &lt;div class="news &lt;?php echo $num; ?&gt;"&gt;
          &lt;div class="four columns"&gt;
              &lt;p&gt;&lt;img src="/news-images/thumbs/thumb_&lt;?php echo $row['newsImage1']; ?&gt;" alt=""/&gt;&lt;/p&gt;
          &lt;/div&gt;
          &lt;div class="eight columns"&gt;
              &lt;h3&gt;&lt;?php echo $row['newsTitle']; ?&gt;&lt;/h3&gt;
              &lt;p&gt;&lt;?php echo stripslashes(strip_tags($row['newsDescription'])); ?&gt;&lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;?php } } else {
  echo "No records found!";
  
  }
  
  if ($rows &gt;= 5) {
  echo "&lt;div class='page-nav blog-nav'&gt;";
      echo $pager-&gt;renderFullNav();
  echo "&lt;/div&gt;";
  }
  ?&gt;
  </code></pre>