Advertisement
LucianoCharles2017

DataTable Itamar

Apr 2nd, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. <?php
  2. $host = 'localhost';
  3. $user = 'root';
  4. $password = '';
  5. $database = 'grupo++';
  6.  
  7. $link = mysqli_connect($host, $user, $password, $database);
  8.  
  9. $sql = "SELECT * FROM usuarios";
  10.  
  11. $query = mysqli_query($link, $sql);
  12. ?>
  13. <html>
  14.     <head>
  15.         <title>DataTable</title>
  16.         <link rel="stylesheet" href="bootstrap3.37.css">
  17.         <link rel="stylesheet" href="dataTable.css">
  18.         <script src="jquery.js"></script>
  19.         <script src="dataTable.js"></script>
  20.     </head>
  21.     <body>
  22.         <div class="container">
  23.             <table id="example" class="table table-striped display" style="width:100%">
  24.                 <thead>
  25.                     <tr>
  26.                         <th>ID</th>
  27.                         <th>NOME</th>
  28.                         <th>IDADE</th>
  29.                     </tr>
  30.                 </thead>
  31.                 <tbody>
  32.                     <?php
  33.                     while ($row = mysqli_fetch_array($query)) {
  34.                         ?>
  35.                         <tr>
  36.                             <td><?php echo $row['id']; ?></td>
  37.                             <td><?php echo $row['nome']; ?></td>
  38.                             <td><?php echo $row['idade']; ?></td>
  39.                         </tr>
  40.                         <?php
  41.                     }
  42.                     ?>
  43.                 </tbody>
  44.                 <tfoot>
  45.                     <tr>
  46.                         <th>ID</th>
  47.                         <th>NOME</th>
  48.                         <th>IDADE</th>
  49.                     </tr>
  50.                 </tfoot>
  51.             </table>
  52.         </div>
  53.         <script>
  54.             $(document).ready(function() {
  55.                 $('#example').DataTable();
  56.             });
  57.         </script>
  58.     </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement