title: PHP: apply CSS to every second row
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2570925/how-to-set-alternate-row-color-for-an-iterated-table-in-php">How to set alternate row color for an iterated table in php?</a><br>
    <a href="https://stackoverflow.com/questions/5080699/using-css-even-and-odd-pseudo-classes-with-list-items">Using CSS :even and :odd pseudo-classes with list items</a>  </p>
  </blockquote>
  
  
  
  <p>I have a html table populated with data from a mysql table.
  I use the following code:</p>
  
  <pre><code>$result = mysql_query("SELECT * FROM {$table}");
  if (!$result) {
  die("Query to show fields from table failed");
  }
  
  $fields_num = mysql_num_fields($result);
  
  echo "&lt;h1&gt;Table: {$table}&lt;/h1&gt;";
  echo "&lt;tr&gt;";
  
  echo "&lt;/tr&gt;\n";
  
  while($row = mysql_fetch_row($result))
  {
  echo "&lt;tr&gt;";
  
  foreach($row as $cell)
      echo "&lt;td&gt;$cell&lt;/td&gt;";
  
  echo "&lt;/tr&gt;\n";
  }
  mysql_free_result($result);
  </code></pre>
  
  <p><strong>Note:</strong> I normally use PDO statments but for this example i use mysql.</p>
  
  <p>The code generate the table correctly. The question is: I want to apply a CSS to every second row with the following <code>class=table_higlight</code>. How can I do this?</p>