CSY2028-assignment-1/public/admin/adminCategories.php

20 lines
697 B
PHP
Raw Normal View History

2022-11-16 13:27:51 +00:00
<?php
session_start();
$pageTitle = 'iBuy - Admin';
$stylesheet = '../assets/ibuy.css';
2022-11-19 15:38:26 +00:00
require_once '../../functions.php';
2022-11-20 21:33:42 +00:00
adminCheck(); //checks to see if user is logged in as admin
2022-11-16 13:27:51 +00:00
$pageContent = '<h1>Categories <a href="addCategory.php">Add</a></h1>
<ul>'. populateContent() .'</ul>';
require '../../layout.php';
function populateContent() {
$output = '';
2022-11-20 21:33:42 +00:00
$cats = fetchCats(); //get all categories
2022-11-16 13:27:51 +00:00
foreach ($cats as &$cat) {
2022-11-19 15:38:26 +00:00
$output .= '<li>'. $cat['name'] . ' <a href="editCategory.php?category_id='. urlencode($cat['category_id']) .'">edit</a> <a href="deleteCategory.php?category_id='. urlencode($cat['category_id']). '">delete</a></li>';
2022-11-16 13:27:51 +00:00
}
return $output;
}
?>