removed people from search results

This commit is contained in:
Johannes Olzem 2023-07-06 01:40:29 +02:00
parent fafe28f9f1
commit a81e438a56
2 changed files with 54 additions and 41 deletions

View File

@ -16,7 +16,6 @@ $conn = new mysqli($env["HOST"], $env["DBUSER"], $env["DBPASS"], $env["TABLE"]);
if($conn->connect_error) { if($conn->connect_error) {
die("Database connection failed: " . $conn->connect_error); die("Database connection failed: " . $conn->connect_error);
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@ -25,10 +24,11 @@ if($conn->connect_error) {
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body> <body>
<h1>CineTrack</h1>
<h2>Willkommen, <?php echo $username; ?>!</h2> <h2>Willkommen, <?php echo $username; ?>!</h2>
<a href="logout.php">Logout</a> <a href="logout.php">Logout</a>
<br> <br>
<h3>Search Movies, Shows and more...</h3>
<form method="post" action="search.php"> <form method="post" action="search.php">
<input type="text" placeholder="Title" name="term" required> <input type="text" placeholder="Title" name="term" required>
<input value="Search" type="submit"> <input value="Search" type="submit">

View File

@ -15,7 +15,7 @@ $response = $client->request('GET', 'https://api.themoviedb.org/3/search/multi?q
'accept' => 'application/json', 'accept' => 'application/json',
], ],
]); ]);
$json = json_decode($response->getBody())->results; $json = json_decode($response->getBody(), true)["results"];
@ -24,15 +24,21 @@ $json = json_decode($response->getBody())->results;
<!DOCTYPE html> <!DOCTYPE html>
<html></html> <html></html>
<head> <head>
<title>Search - CineTrack</title>
</head> </head>
<body> <body>
<h1>CineTrack</h1>
<a href='/dashboard.php'>Go Back</a>
<?php if(!empty($json)): ?>
<h2>Search results:</h2>
<table style="border: thin solid black;border-collapse: collapse;"> <table style="border: thin solid black;border-collapse: collapse;">
<tr> <tr>
<?php <?php
foreach($json as $data) { foreach($json as $data) {
if(strcasecmp($data["media_type"], "person") === 0) { continue; }
echo "<td style='border: thin solid black;'><img src='https://image.tmdb.org/t/p/original"; echo "<td style='border: thin solid black;'><img src='https://image.tmdb.org/t/p/original";
echo $data->poster_path; echo $data["poster_path"];
echo "' style='width:10rem;'><br></td>"; echo "' style='width:10rem;'><br></td>";
} }
?> ?>
@ -40,10 +46,13 @@ foreach($json as $data) {
<tr> <tr>
<?php <?php
foreach($json as $data) { foreach($json as $data) {
if(strcasecmp($data["media_type"], "person") === 0) { continue; }
echo "<td style='border: thin solid black;'>"; echo "<td style='border: thin solid black;'>";
// title data can either be title or name // title data can either be title or name
echo $data->title; echo $data["title"];
echo $data->name; echo $data["name"];
// only show year when available
echo ($data["first_air_date"] != null) ? " (" . explode("-", $data["first_air_date"])[0] . ")" : '';
echo "</td>"; echo "</td>";
} }
?> ?>
@ -51,10 +60,11 @@ foreach($json as $data) {
<tr> <tr>
<?php <?php
foreach($json as $data) { foreach($json as $data) {
if(strcasecmp($data["media_type"], "person") === 0) { continue; }
echo "<td style='border: thin solid black;'>"; echo "<td style='border: thin solid black;'>";
echo "<form>"; echo "<form>";
echo "<input type='number' name='season' id='season' value='1' style='width:5ch' required>"; echo "<input type='number' name='season' id='season' value='1' min='1' style='width:5ch' required>";
echo "<input type='number' name='episode' id='episode' value='1' style='width:5ch' required>"; echo "<input type='number' name='episode' id='episode' value='1' min='1' style='width:5ch' required>";
echo "<label for='season'>S</label>"; echo "<label for='season'>S</label>";
echo "<label for='episode'>Ep</label><br>"; echo "<label for='episode'>Ep</label><br>";
echo "<input type='submit' value='Add/Change'><br>"; echo "<input type='submit' value='Add/Change'><br>";
@ -64,5 +74,8 @@ foreach($json as $data) {
?> ?>
</tr> </tr>
</table> </table>
<?php else: ?>
<h2>Nothing found...</h2>
<?php endif ?>
</body> </body>
</html> </html>