Guest User

Untitled

a guest
Feb 11th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <?php
  2. include('connect.php');
  3. ?>
  4.  
  5. <html>
  6. <head>
  7. <title>pro tytul</title>
  8. <style type="text/css">
  9. .table_titles, .table_cells_odd, .table_cells_even {
  10. padding-right: 20px;
  11. padding-left: 20px;
  12. color: #000;
  13. }
  14. .table_titles {
  15. color: #FFF;
  16. background-color: #666;
  17. }
  18. .table_cells_odd {
  19. background-color: #CCC;
  20. }
  21. .table_cells_even {
  22. background-color: #FAFAFA;
  23. }
  24. table {
  25. border: 2px solid #333;
  26. }
  27. body { font-family: "Trebuchet MS", Arial; }
  28. </style>
  29. </head>
  30.  
  31. <body>
  32. <h1>pro tabela</h1>
  33. <table border="0" cellspacing="0" cellpadding="4">
  34. <tr>
  35. <td class="table_titles">id</td>
  36. <td class="table_titles">test</td>
  37. <td class="table_titles">abc</td>
  38. </tr>
  39. <?php
  40. $result = mysql_query("SELECT * FROM testabc ORDER BY id DESC");
  41.  
  42. $oddrow = true;
  43.  
  44. while( $row = mysql_fetch_array($result) )
  45. {
  46. if ($oddrow)
  47. {
  48. $css_class=' class="table_cells_odd"';
  49. }
  50. else
  51. {
  52. $css_class=' class="table_cells_even"';
  53. }
  54.  
  55. $oddrow = !$oddrow;
  56.  
  57. echo '<tr>';
  58. echo ' <td'.$css_class.'>'.$row["id"].'</td>';
  59. echo ' <td'.$css_class.'>'.$row["test"].'</td>';
  60. echo ' <td'.$css_class.'>'.$row["abc"].'</td>';
  61. echo '</tr>';
  62. }
  63. ?>
  64. </table>
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment