echo $_GET["firstname"] . " " . $_GET["lastname"]; ?> </h1> <div id="title"> Films with <?php echo $_GET["firstname"] . " " . $_GET["lastname"]; ?> </div> <table> <?php include 'common.php'; $conn = getdataconnection(); $fname = $_GET["firstname"]; $lname = $_GET["lastname"]; $id_actor = getactorid($fname, $lname); foreach ($id_actor as $id) { $actor_id = $id['id']; } if (isset($actor_id)) { $sql = $conn->query("SELECT movie.year, movie.name FROM movies movie JOIN roles role ON role.movie_id = movie.id JOIN actors actor ON role.actor_id = actor.id WHERE role.actor_id = '" . $actor_id . "' ORDER BY movie.year DESC, movie.name ASC"); $row_num = 0; createtablehead(); foreach ($sql as $row) { echo "<tr><td>"; echo $row_num + 1; echo "</td><td>"; echo $row['name']; echo "</td><td>"; echo $row['year']; echo "</td></tr>";
<?php include "top.html"; include "common.php"; ?> <?php if ($_SERVER['REQUEST_METHOD'] == 'GET') { $fn = $_GET['firstname']; $ln = $_GET['lastname']; $id = getactorid($fn, $ln, $db); // obtain the id for the actor /* Search for the movie*/ $stmt = $db->prepare('select m.name, m.year from actors a join actors a2 join roles r join roles r2 join movies m where a.id=:id and a2.first_name = "Kevin" and a2.last_name = "Bacon" and a.id = r.actor_id and r.movie_id = m.id and a2.id = r2.actor_id and r2.movie_id = m.id order by m.year desc'); $stmt->bindParam(':id', $id); $stmt->execute(); $rows = $stmt->fetchAll(); } ?> <h1>Result for <?php print $fn . " " . $ln; ?> </h1> <p>Films with <?php print $fn . " " . $ln; ?>