View sourcecode

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

index.php

75 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
<?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>HogeNView</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>
    <style>
        .link-unchanged {
            text-decoration: unset;
            color: unset;
        }
    </style>
</head>

<body>
    <?php include "page/navbar.php" ?>
    <div class="container">
        <br>
        <h1>Dina filmkategorier</h1>
        <br>
        <?php
        $data 
$db->queryAll("SELECT c.* FROM allowedIDs a INNER JOIN category c ON a.categoryID = c.categoryID WHERE userID=:userID", array("userID" => $_SESSION["userID"]));
        if(
$data == null){
            echo 
'<h5 class="text-center" style="color: rgb(100,100,100)";>Du har inga tillgängliga filmer.</h5>';
        }
        
$cardRowSize 2;

        function 
print_cell($data)
        {
            if (isset(
$data))
                echo <<<EOD
            <div class="col">
                <a href="category.php?id=
{$data['categoryID']}" class="link-unchanged">
                    <div class="card">
                        <div class="card-body">
                            <h5 class="card-title">
{$data["name"]}</h5>
                            <p class="card-text">
{$data["description"]}</p>
                        </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>';
        }
        
?>
    </div>
</body>

</html>