The following files exists in this folder. Click to view.
category.php80 lines UTF-8 Unix (LF) 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
<?php
session_start();
if (!isset($_SESSION["userID"]))
header("location: login.php");
require_once "functions/database.php";
?>
<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Choose Media</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"
integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI"
crossorigin="anonymous"></script>
</head>
<body>
<?php include "page/navbar.php" ?>
<div class="container">
<br>
<?php
$categoryData = $db->query("SELECT c.* FROM allowedIDs a INNER JOIN category c ON a.categoryID = c.categoryID WHERE a.userID=:userID AND a.categoryID=:categoryID",
array("userID"=> $_SESSION["userID"],"categoryID" => $_GET['id']));
if(!$categoryData){
echo "<p>Nekad tillgÄng.</p>";
} else{
#echo "<pre>"; var_export($categoryData); echo "</pre>";
echo "<h1>{$categoryData['name']}</h1>";
echo "<h5>{$categoryData['description']}</h5>";
$data = $db->queryAll("SELECT * FROM mediaFiles f WHERE f.categoryID=:categoryID",
array("categoryID" => $_GET['id']));
#echo "<pre>"; var_export($data); echo "</pre>";
if($data == null){
echo '<h5 class="text-center" style="color: rgb(100,100,100)";>Inga filmer finns inom kategorin.</h5>';
}
$cardRowSize = 2;
function print_cell($data)
{
if (isset($data))
echo <<<EOD
<div class="col">
<a href="movie.php?id={$data['mediaID']}" class="link-unchanged">
<div class="card">
<div class="card-body">
<h5 class="card-title">{$data["name"]}</h5>
</div>
</div>
</a>
</div>
EOD;
else
echo '<div class="col"></div>';
}
for ($row = 0; $row < ceil(sizeof($data) / $cardRowSize); $row++) {
echo '<div class="row">';
for ($col = 0; $col < $cardRowSize; $col++) {
if (isset($data[$row * $cardRowSize + $col]))
print_cell($data[$row * $cardRowSize + $col]);
else
print_cell(null);
}
echo '</div><br>';
}
}
?>
<br>
</div>
</body>
</html>