Guest User

Untitled

a guest
Nov 1st, 2025
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <link href="css/bootstrap.min.css" rel="stylesheet">
  6.  
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h3>Album Charts '71</h3>
  12. </div>
  13.  
  14. <div class="row">
  15. <table class="table table-striped table-bordered">
  16. <thead>
  17. <tr>
  18. <th>Artist</th>
  19. <th>Album</th>
  20. <th>Weeks</th>
  21. </tr>
  22. </thead>
  23. <tbody>
  24.  
  25. <?php
  26. include('connect.php');
  27.  
  28. $sql = "SELECT * FROM charts";
  29. $statement = $pdo->query($sql);
  30. $charts = $statement->fetchAll();
  31.  
  32. /*the foreach() loop only works on arrays.
  33. For every iteration, the value of the current array element is assigned to $row and
  34. the array pointer then moves on by one, until it reaches the last element of the array*/
  35.  
  36.  
  37. foreach ($charts as $row) {
  38. echo '<tr>';
  39.  
  40. echo '<td>'. $row['artist'] . '</td>';
  41.  
  42. echo '<td>'. $row['album'] . '</td>';
  43.  
  44. echo '<td>'. $row['weeks'] . '</td>';
  45.  
  46. echo '</tr>';
  47.  
  48. }
  49.  
  50. ?>
  51.  
  52. </tbody>
  53. </table>
  54. </div>
  55. </div>
  56. </body>
  57. </html>
  58.  
Advertisement
Add Comment
Please, Sign In to add comment