Posted By

davidsword on 09/20/08


Tagged

highlight odd even


Versions (?)

highlight even/odd list from database


 / Published in: PHP
 

URL: http://davidsword.ca/

  1. $query = "SELECT * FROM table";
  2. $result = mysql_query($query);
  3. $i = 1;
  4. while($row = mysql_fetch_array($result)){
  5. if ($i % 2) {echo"<div style='background:#eaeaea;'>".$row['content']."</div>";}
  6. else {echo $row['content'];}
  7. $i++;
  8. }

Report this snippet  

You need to login to post a comment.