-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategories.php
72 lines (62 loc) · 2.14 KB
/
categories.php
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
<?php
/*******w********
Name: James Hamilton
Date: November 14, 2023
Description: A webpage for MyBassGallery that allows users to view all page categories.
****************/
// There must be a DB connection to continue.
require('connect.php');
// Include the utility functions file.
require('utility.php');
// Start/Resume the session.
session_start();
// Get list of categories from the categories table.
$categories = "SELECT * FROM categories;";
$categoriesStatement = $db->prepare($categories);
$categoriesStatement->execute();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Categories - MyBassGallery</title>
</head>
<body>
<nav class='navbar'>
<a href="index.php">
<div class="logo">
<img src="uploads/mbg-logo.png" width="70px">
<h1>MyBassGallery</h1>
</div>
</a>
<?php if(empty($_SESSION)) : ?>
<div class="links">
<a href="register.php">Register</a>
<a href="login.php">Login</a>
</div>
<?php else : ?>
<div class="links">
<a href="create.php">Create a Post</a>
<?php if(checkUserType() == 1) : ?>
<a href="adminManageUsers.php">Manage Users</a>
<a href="adminManageCategories.php">Manage Categories</a>
<?php endif ?>
<a class="username"><?= $_SESSION['user']['userName'] ?></a>
<a href="login.php">Logout</a>
</div>
<?php endif ?>
</nav>
<h1 id="category-title">Categories: </h1>
<div id="category-container">
<?php while($category = $categoriesStatement->fetch()) : ?>
<a href="postsByCategory.php?id=<?= $category['categoryID'] ?>">
<div class="category-select">
<?= $category['categoryName'] ?>
</div>
</a>
<?php endwhile ?>
</div>
</body>
</html>