<?php session_start(); include "../dvd-lib-common/head.php"; require_once "dvd-db.php"; require_once "dvd-util.php"; if (array_key_exists('genre', $_GET)) { try { $genre_found = $_GET['genre']; $dvds = get_dvds_for_genre($genre_found); if (sizeof($dvds) > 0) { if (sizeof($dvds) == 1) { #display single dvd echo "<h2>One match found: </h2><br />\n<table cellpadding=5>\n"; echo "<tr><th>Title</th><td>{$dvds[0][0]}</td></tr>\n"; echo "<th>Release Year</th><td>{$dvds[0][1]}</td></tr>\n"; echo "<th>Director</th><td>{$dvds[0][2]}</td></tr>\n"; echo "<th>Rating</th><td>{$dvds[0][3]}</td></tr>\n"; echo "<th>Genre</th><td>{$dvds[0][4]}</td></tr>\n"; echo "</table><hr />"; } else { echo "<h2>Possible Matches</h2><br />"; echo "<table cellpadding=5>\n<tr><th>Title</th><th>Release Year</th>\n <th>Director</th><th>Rating</th><th>Genre</th></tr>"; foreach ($dvds as $dvd) { echo "<tr>\n"; echo "<td><a href='view_dvd.php?part_title={$dvd[0]}'>{$dvd[0]}</a></td>"; for ($i = 1; $i < sizeof($dvd); $i++) { echo "<td>{$dvd[$i]}</td>"; } echo "</tr>\n"; }
public function testGetDVDsForGenre() { $this->assertTrue(sizeof(get_dvds_for_genre($this->genre)) > 0, "Should be dvd's in the {$this->genre} genre"); }