View sourcecode

The following files exists in this folder. Click to view.

category.php

80 lines UTF-8 Unix (LF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?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>