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) {
die("Database connection failed: " . $conn->connect_error);
}
?>
<!DOCTYPE html>
<html>
@ -25,10 +24,11 @@ if($conn->connect_error) {
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>CineTrack</h1>
<h2>Willkommen, <?php echo $username; ?>!</h2>
<a href="logout.php">Logout</a>
<br>
<h3>Search Movies, Shows and more...</h3>
<form method="post" action="search.php">
<input type="text" placeholder="Title" name="term" required>
<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',
],
]);
$json = json_decode($response->getBody())->results;
$json = json_decode($response->getBody(), true)["results"];
@ -24,45 +24,58 @@ $json = json_decode($response->getBody())->results;
<!DOCTYPE html>
<html></html>
<head>
<title>Search - CineTrack</title>
</head>
<body>
<table style="border: thin solid black;border-collapse: collapse;">
<tr>
<?php
foreach($json as $data) {
<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;">
<tr>
<?php
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 $data->poster_path;
echo "'style='width:10rem;'><br></td>";
}
?>
</tr>
<tr>
<?php
foreach($json as $data) {
echo $data["poster_path"];
echo "' style='width:10rem;'><br></td>";
}
?>
</tr>
<tr>
<?php
foreach($json as $data) {
if(strcasecmp($data["media_type"], "person") === 0) { continue; }
echo "<td style='border: thin solid black;'>";
// title data can either be title or name
echo $data->title;
echo $data->name;
echo $data["title"];
echo $data["name"];
// only show year when available
echo ($data["first_air_date"] != null) ? " (" . explode("-", $data["first_air_date"])[0] . ")" : '';
echo "</td>";
}
?>
</tr>
<tr>
<?php
foreach($json as $data) {
}
?>
</tr>
<tr>
<?php
foreach($json as $data) {
if(strcasecmp($data["media_type"], "person") === 0) { continue; }
echo "<td style='border: thin solid black;'>";
echo "<form>";
echo "<input type='number' name='season' id='season' value='1' style='width:5ch' required>";
echo "<input type='number' name='episode' id='episode' 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' min='1' style='width:5ch' required>";
echo "<label for='season'>S</label>";
echo "<label for='episode'>Ep</label><br>";
echo "<input type='submit' value='Add/Change'><br>";
echo "</form>";
echo "</td>";
}
?>
</tr>
</table>
}
?>
</tr>
</table>
<?php else: ?>
<h2>Nothing found...</h2>
<?php endif ?>
</body>
</html>