highlight even/odd list from database


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



Copy this code and paste it in your HTML
  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. }

URL: http://davidsword.ca/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.