Assignment 1

In this assignment, you will build two pages that read from the chinook SQLite database.

The playlist list page

Create playlists.php and display all playlist names ordered alphabetically.

Each playlist should link to playlist.php?id=PLAYLIST_ID, where PLAYLIST_ID is replaced by the ID of the playlist.

The playlist details page

At the top of playlist.php, display the playlist name in the header. This should be a new query using the id query string param. You can use fetch instead of fetchAll to query for a single record.

This page should display all tracks for the playlist with the id found in the id query string parameter. For each track, display the following information in an HTML table:

  • Track name
  • Album title
  • Artist name
  • Price
  • Genre name

The tracks should be sorted by the track name.

If there is no id query string parameter, redirect back to playlists.php.

If a playlist doesn't have any tracks, display in a p tag, "No tracks found for the PLAYLIST NAME HERE playlist." where PLAYLIST NAME HERE is the name of the playlist. In this case, the table shouldn't render. Hint, use PHP's alternate syntax for if statements. For example:

<?php if (true) : ?>
  <p>Foo</p>
<?php else : ?>
  <p>Bar</p>
<?php endif ?>

Code Requirements

  • All queries should use the PDO class.
  • Use parameter binding for any untrusted data, like query string parameters.

Submission

Create a video with audio using Zoom where you demo your assignment and explain where you fulfilled or did not fulfill each requirement. Put a link to this recording in a README.md file at the root of your project.

https://classroom.github.com/a/5_AxP1Ye