I'm so sorry if this doesn't make any sense at all. I've created a PHP file called "filmdetails.php" that will list all details of a given film:
<?php
require_once 'dbcon_sakila.php';
$film_id = $_GET['filmid'];
$sql = 'SELECT title, description, release_year, rental_duration, rental_rate, length, replacement_cost, rating, special_features, film.last_update, category.name, actor.first_name, actor.last_name
FROM film, film_category, category, film_actor, actor
WHERE film.film_id = film_category.film_id
AND category.category_id = film_category.category_id
AND film.film_id = film_actor.film_id
AND film_actor.actor_id = actor.actor_id
AND film.film_id = ?';
$stmt = $link->prepare($sql);
$stmt->bind_param('i', $film_id);
$stmt->bind_result($title, $description, $release_year, $rental_duration, $rental_rate, $length, $replacement_cost, $rating, $special_features, $last_update, $category_name, $first_name, $last_name);
$stmt->execute();
while ($stmt->fetch()) {
echo '<p>Title: ' . $title . '</p>';
echo '<p>Description: ' . $description . '</p>';
echo '<p>Release year: ' . $release_year . '</p>';
echo '<p>Rental duration: ' . $rental_duration . '</p>';
echo '<p>Rental rate: ' . $rental_rate . '</p>';
echo '<p>Length: ' . $length . '</p>';
echo '<p>Replacement cost: ' . $replacement_cost . '</p>';
echo '<p>Rating: ' . $rating . '</p>';
echo '<p>Special features: ' . $special_features . '</p>';
echo '<p>Last updated: ' . $last_update . '</p>';
echo '<p>Categories: ' . $category_name . '</p>';
echo '<p>First name: ' . $first_name . '</p>';
echo '<p>Last name: ' . $last_name . '</p>';
}
?>
The problem is when I choose a specific film (in my browser) it repeats itself but with the different actors in the film.
Example:
Title: ALLEY EVOLUTION
Description: A Fast-Paced Drama of a Robot And a Composer who must Battle a Astronaut in New Orleans
Release year: 2006
Rental duration: 6
Rental rate: 2.99
Length: 180
Replacement cost: 23.99
Rating: NC-17
Special features: Trailers,Commentaries
Last updated: 2006-02-15 05:03:42
Categories: Foreign
First name: KARL
Last name: BERRY
Title: ALLEY EVOLUTION
Description: A Fast-Paced Drama of a Robot And a Composer who must Battle a Astronaut in New Orleans
Release year: 2006
Rental duration: 6
Rental rate: 2.99
Length: 180
Replacement cost: 23.99
Rating: NC-17
Special features: Trailers,Commentaries
Last updated: 2006-02-15 05:03:42
Categories: Foreign
First name: JUDE
Last name: CRUISE
and so on...
How do I prevent this? Do I really have to make more SELECT statements?