Example #1
0
<!--
    View to see individual movie's detail page.
    First require the necessary model and connection details, 
    then retrieve the movie's id. Set up the connection, and get the
    row of data from the database with that id
-->
<?php 
require_once '../models/model.php';
require_once '../connection.php';
$id = $_GET['id'];
$conn = getConnection();
$model = new Model($conn);
$movie = $model->movDetails($id)[0];
$imdb_id = $model->movDetails($id)[0]['imdb_id'];
// request and parse json from rottentomatoes api
$url = "http://www.omdbapi.com/?i={$imdb_id}&tomatoes=true";
$json = file_get_contents($url);
$result = json_decode($json);
// decode the json object
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Detail page</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" >
    
    <link rel="stylesheet" href="../css/main.css" >
</head>
<body>