Advertisement
haikelfazzani

Display Data From MySQL Database Using Php

Jul 25th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. <?php
  2.     require_once("connection.php");
  3.    
  4.     $sql = "SELECT * FROM upload";
  5.    
  6.     $stmt = $connect->prepare($sql);
  7.    
  8.     $stmt->execute();
  9.    
  10. ?>
  11.  
  12. <?php require_once("menu.html"); ?>
  13.  
  14. <center>
  15.  
  16. <div class="container">
  17.        
  18.     <h2>codeJs : Display Data</h2>
  19.                            
  20.         <table align='center' class="table table-bordered">
  21.                
  22.             <thead>
  23.                 <tr>
  24.                     <th>Order</th>
  25.                     <th>Username</th>
  26.                     <th>Gender</th>
  27.                     <th>Country</th>
  28.                     <th>Date</th>
  29.                 </tr>
  30.             </thead>
  31.                    
  32.             <tbody>
  33.            
  34.                 <?php $i = 0 ; while($res = $stmt->fetch()){ $i++; ?>
  35.                 <tr>
  36.                     <td><?php echo $i; ?></td>
  37.                     <td><?php echo $res["username"]; ?></td>
  38.                     <td><?php echo $res["gender"]; ?></td>
  39.                     <td><?php echo $res["country"]; ?></td>
  40.                     <td><?php echo $res["date"]; ?></td>
  41.                 <?php } ?>
  42.                 </tr>
  43.  
  44.             </tbody>
  45.         </table>
  46.            
  47. </div>
  48.    
  49. </center>
  50. <style>
  51. thead tr:nth-child(1){ background: #4e6caf; color: white; }
  52. tbody tr{ background: #fff; }
  53. img{ width: 50px; height: 50px; }
  54. </style>
  55.  
  56. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  57. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement