Advertisement
AbsolutelyHorrible

gen table

Nov 24th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.44 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang = "sr">
  3.   <head>
  4.     <meta charset = "UTF-8">
  5.     <!-- Reset za CSS-->
  6.     <link rel="stylesheet" type="text/css" href = "http://meyerweb.com/eric/tools/css/reset/reset.css">
  7.     <title>Raspored Časova</title>
  8.  
  9.     <style type="text/css">
  10.       table {
  11.         margin: 0 auto;
  12.         border: 1px solid #ccc;
  13.         text-align: left;
  14.       }
  15.  
  16.       th {
  17.         font-weight: bold;
  18.       }
  19.  
  20.       td, th {
  21.         padding: 7px 150px 7px 7px;
  22.         border-bottom: 1px solid #ccc;
  23.       }
  24.  
  25.       tr {
  26.         background: #fff;
  27.       }
  28.  
  29.       tbody tr:nth-of-type(odd) {
  30.         background: #ddd;
  31.       }
  32.     </style>
  33.   </head>
  34.  
  35.   <body>
  36.     <?php
  37.         function printTable($table) {
  38.             $tableLen = count($table);
  39.             for ($i = 0; $i < $tableLen; $i++) {
  40.                 echo "<tr>\n";
  41.                 for ($x = 0; $x < 4; $x++) {
  42.                     echo "<td>" . $table[$i][$x] . "</td>\n";
  43.                 };
  44.                 echo "</tr>\n";
  45.             };
  46.         };
  47.     ?>
  48.     <table>
  49.       <thead>
  50.         <tr>
  51.           <th>ID</th>
  52.           <th>First Name</th>
  53.           <th>Last Name</th>
  54.           <th>Email</th>
  55.         </tr>
  56.       </thead>
  57.      
  58.       <tfoot></tfoot>
  59.  
  60.       <tbody>
  61.         <?php
  62.         $users = array(
  63.             array("1", "Peter", "Andersen", "peter@gmail.com"),
  64.             array("2", "John", "Miller", "john@gmail.com"),
  65.             array("3", "Thomas", "Swift", "thomas@gmail.com")
  66.             );
  67.    
  68.         printTable($users);
  69.     ?>
  70.       </tbody>
  71.     </table>
  72.   </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement