PHP Lab 3: Database

For this lab, you can rely on what we have seen about the database.

List of series

Write a page that displays the list of series from the shows database whose name starts with L (using PDO)

You can tell MySQL which character set to use with the following query:

<?php
$pdo->query('SET CHARSET UTF8');

Form and database

Write a page with a form that leads to a second page displaying the list of series whose initial letter is given through the form.

Displaying the posters

Improve the page so that it displays the posters. They are stored in the database in the poster field of the series table.

Hints:

  • The poster column contains the JPEG data of the poster
  • Start by creating a poster.php page that displays the poster of a series whose id is passed as a GET parameter (watch out for the Content-type).

List of seasons

Add a link on the name of a series that leads to the list of its seasons, each with the number of episodes in that season.

For example:

  • Season 1 (10 episodes)
  • Season 2 (12 episodes)
  • Season 3 (8 episodes)

Pagination

You can fetch only a given number of results (for example 10) starting from a given result (for example the 5th):

SELECT * FROM series LIMIT 5, 10

Using this query, implement pagination of the series, so that only 10 are displayed per page, and you can navigate between pages.

Warning: it is not possible to pass the LIMIT values as prepared parameters. Here, you can concatenate them to the beginning of the query instead.