generated from francesco/deploy-dinamico
This commit is contained in:
159
file/film/index.php
Normal file
159
file/film/index.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
if (isset($_GET['s'])) {
|
||||
highlight_file("index.php");
|
||||
return;
|
||||
}
|
||||
|
||||
// Ricerca film dal DB
|
||||
|
||||
$conn = mysqli_connect("localhost", "root", "", "film_attori");
|
||||
|
||||
if ($conn === false) {
|
||||
exit("<code>Errore: impossibile stabilire una connessione " . mysqli_connect_error() . "</code>");
|
||||
}
|
||||
// Collegamento al DB effettuato
|
||||
|
||||
// Leggo ID
|
||||
if (!isset($_GET['id'])) {
|
||||
// Codice HTTP 404: Not found
|
||||
http_response_code(404);
|
||||
echo "<code>Film non trovato!</code>";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_numeric($_GET['id']) || $_GET['id'] === "" || $_GET['id'] === null) {
|
||||
// Codice HTTP 404: Not found
|
||||
http_response_code(404);
|
||||
echo "<code>Film non trovato!</code>";
|
||||
return;
|
||||
}
|
||||
|
||||
$idFilm = intval($_GET['id']);
|
||||
$query = "SELECT film.id_film, film.nome, film.trama, film.durata, film.data_uscita, generi.nome as genere FROM film, generi WHERE film.id_genere = generi.id_genere AND film.id_film = " . $idFilm . " ORDER BY film.data_uscita";
|
||||
|
||||
// Leggo i dati del film e faccio il JOIN per avere il nome del genere
|
||||
$res = mysqli_query($conn, $query);
|
||||
|
||||
if ($res === false) {
|
||||
// Codice HTTP 500: Errore
|
||||
http_response_code(500);
|
||||
echo "<code>Errore: impossibile eseguire la query. " . mysqli_error($conn) . "</code>";
|
||||
mysqli_close($conn);
|
||||
exit();
|
||||
}
|
||||
|
||||
$row = mysqli_fetch_array($res);
|
||||
|
||||
mysqli_free_result($res);
|
||||
|
||||
if (!$row) {
|
||||
// Codice HTTP 404: Not found
|
||||
http_response_code(404);
|
||||
echo "<code>Film non trovato!</code>";
|
||||
mysqli_close($conn);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ottengo gli attori
|
||||
$queryAttori = "SELECT attori.nome, attori.cognome, attori.data_nascita, recitare.ruolo FROM attori, recitare WHERE attori.id_attore = recitare.id_attore AND recitare.id_film = " . $idFilm . " ORDER BY recitare.ruolo DESC ";
|
||||
|
||||
$resAttori = mysqli_query($conn, $queryAttori);
|
||||
|
||||
if ($resAttori === false) {
|
||||
// Codice HTTP 500: Errore
|
||||
http_response_code(500);
|
||||
echo "<code>Errore: impossibile eseguire la query. " . mysqli_error($conn) . "</code>";
|
||||
mysqli_close($conn);
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo $row["nome"]; ?> - Film - The NoSpace Cinema</title>
|
||||
<!--- www.francescomancuso.it -->
|
||||
<link rel="stylesheet" href="../style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<div class="container">
|
||||
<a href="../" style="text-decoration: none;">
|
||||
<div>
|
||||
<img src="../logo.png">
|
||||
<h4>The NoSpace Cinema</h4>
|
||||
</div>
|
||||
</a>
|
||||
<div>
|
||||
<a href=".?s" style="font-size:16px">Vedi sorgente pagina</a>
|
||||
<a href="../search/" class="button">Tutti i film</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div class="container">
|
||||
<div class="hero film" style="background-image: url('<?php echo "../api/v1/img/?n=" . urlencode($row['nome'] . ' ' . date('Y', strtotime($row['data_uscita']))); ?>')">
|
||||
<div>
|
||||
<h1><?php echo $row["nome"]; ?></h1>
|
||||
<div class="genere">
|
||||
<?php echo $row["genere"]; ?>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<span><?php echo date("d M Y", strtotime($row["data_uscita"])); ?></span>
|
||||
<span>|</span>
|
||||
<span><?php echo $row["durata"]; ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<img src="<?php echo "../api/v1/img/?n=" . urlencode($row['nome'] . ' ' . date('Y', strtotime($row['data_uscita']))); ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="page film">
|
||||
<div class="container">
|
||||
<h2>Trama</h2>
|
||||
<div class="trama">
|
||||
<?php echo $row['trama']; ?>
|
||||
</div>
|
||||
|
||||
<h2>Attori</h2>
|
||||
<div class="grid films">
|
||||
<?php
|
||||
$test = true;
|
||||
while ($rowAttori = mysqli_fetch_array($resAttori)) {
|
||||
$test = false;
|
||||
?>
|
||||
<div class="attore">
|
||||
<img src="../attore-list.png">
|
||||
<h5><?php echo $rowAttori['nome']; ?> <?php echo $rowAttori['cognome']; ?></h5>
|
||||
<span>Nato/a il <?php echo date("d M Y", strtotime($rowAttori['data_nascita'])); ?></span>
|
||||
<div class="ruolo">
|
||||
<?php echo $rowAttori['ruolo']; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
mysqli_free_result($resAttori);
|
||||
mysqli_close($conn);
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
// Nessun risultato...
|
||||
if ($test) {
|
||||
echo "<div class=\"container\">Nessun attore trovato!</div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
<div class="container">
|
||||
<span>Realizzato da Francesco Giuseppe Mancuso - classe 5E - www.francescomancuso.it</span>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user