Colorear filas de una tabla par/impar con PHP


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $i = 0;
  2.  
  3. foreach($rows as $row) {
  4. $class = ($i++ & 1) == 1 ? 'odd' : 'even';
  5.  
  6. echo '<tr>';
  7. echo "<td class=\"{$class}\">{$row['name']}</td>";
  8. echo "<td class=\"{$class}\">{$row['phone']}</td>";
  9. echo '</tr>';
  10.  
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.