Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <link href="css/bootstrap.min.css" rel="stylesheet">
- </head>
- <body>
- <div class="container">
- <div class="row">
- <h3>Album Charts '71</h3>
- </div>
- <div class="row">
- <table class="table table-striped table-bordered">
- <thead>
- <tr>
- <th>Artist</th>
- <th>Album</th>
- <th>Weeks</th>
- </tr>
- </thead>
- <tbody>
- <?php
- include('connect.php');
- $sql = "SELECT * FROM charts";
- $statement = $pdo->query($sql);
- $charts = $statement->fetchAll();
- /*the foreach() loop only works on arrays.
- For every iteration, the value of the current array element is assigned to $row and
- the array pointer then moves on by one, until it reaches the last element of the array*/
- foreach ($charts as $row) {
- echo '<tr>';
- echo '<td>'. $row['artist'] . '</td>';
- echo '<td>'. $row['album'] . '</td>';
- echo '<td>'. $row['weeks'] . '</td>';
- echo '</tr>';
- }
- ?>
- </tbody>
- </table>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment