Posted By

Darksider3 on 07/26/11


Tagged

mysql select php table html color snippet tag different LDG pf-control


Versions (?)

Make your table color different by Mysql Select tag


 / Published in: PHP
 

URL: http://darksider3.pf-control.de/all/scripts.php?id=Abwechselnde%20Tabellenfarben%28MYSQL-SELECT

Here you see a example to make your table background color fdifferent at last

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Abwechselnde Zeilenfarben(MYSQL)</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <style type="text/css">
  7. <!--
  8. .tableLine
  9. {
  10. font-family: Verdana,Arial,sans-serif;
  11. font-style: normal;
  12. font-size: 14px;
  13. BORDER-TOP: #A6A6A6 1px solid;
  14. BORDER-LEFT: #A6A6A6 1px solid;
  15. BORDER-BOTTOM: #A6A6A6 1px solid;
  16. BORDER-RIGHT: #A6A6A6 1px solid;
  17. }
  18. .row_0 {
  19. background-color: #FFFFFF;
  20. }
  21. .row_1 {
  22. background-color: #E1E8F1;
  23. }
  24. -->
  25. </style>
  26. </head>
  27. <body>
  28. <table width="100%" border="0" cellpadding="0" cellspacing="0"
  29. class="tableLine" height="100%">
  30. <?php
  31. mysql_connect(''localhost'', ''root'', ''****'');
  32. mysql_select_db("ldg-php");
  33. $sql = mysql_query(''SELECT * FROM news'');
  34. while($res= mysql_fetch_array($sql)){
  35. if($res[''id''] % 2){
  36. echo "<tr><td class=''row_0''>Eintrag nr. $res[id]<br />$res[text]</td></tr>";
  37. }
  38. else {
  39. echo "<tr><td class=''row_1''>Eintrag nr. $res[id]<br />$res[text]</td></tr>";
  40. }
  41. }
  42. echo "</table>";
  43. ?>

Report this snippet  

You need to login to post a comment.