Add_category.php

<?php
//get the input data//
$categoryName=filter_input(INPUT_POST,'category_name');


require_once('database.php');
  
//add into database//
$query = 'INSERT INTO categories
            (categoryName)
          VALUES
            (:categoryName)';
$statement = $db->prepare($query);
$statement->bindValue(':categoryName',$categoryName);
$statement->execute();
$statement->closeCursor();

//display the categories list//
include('category_list.php');

 ?>

category_list.php

<?php
require_once('database.php');

// Get all categories
$query = 'SELECT * FROM categories
          ORDER BY categoryID';
$statement = $db->prepare($query);
$statement->execute();
$categories = $statement->fetchAll();
$statement->closeCursor();
?>
<!DOCTYPE html>
<html>

<!-- the head section -->
<head>
    <title>My Guitar Shop</title>
    <link rel="stylesheet" href="main.css" />
</head>

<!-- the body section -->
<body>
<header><h1>Product Manager</h1></header>
<main>
    <h1>Category List</h1>
    <table>
        <tr>
            <th>Name</th>
            <th>&nbsp;</th>
        </tr>

        <!-- add code for the rest of the table here -->
    <?php foreach ($categories as $categories) : ?>
      <tr>
        <td><?php echo $categories["categoryName"] ?></td>
        <td>
            <form action="delete_category.php" method="post">
              <input type="hidden" name="category_id"
                value="<?php echo $categories['categoryID']; ?>">
                <input type="submit" value="Delete">
            </form>    
        </td>
      </tr>
      <?php endforeach; ?>
    </table>

    <h2>Add Category</h2>

    <!-- add code for the form here -->
    <form action="add_category.php" method="post"
      id="add_category_form">

      <label for="category_name">Category Name:</label>
      <input type="text" name="category_name">
      <label>&nbsp;</label>
      <input type="submit" value="Add">
    </form>
    <br>
    <p><a href="index.php">List Products</a></p>

    </main>

    <footer>
        <p>&copy; <?php echo date("Y"); ?> My Guitar Shop, Inc.</p>
    </footer>
</body>
</html>

delete_product.php

<?php
require_once('database.php');
//get ids//
$category_id=filter_input(INPUT_POST,'category_id');
//statments to delete//
$query = 'DELETE FROM categories
          WHERE categoryID =:category_id';
    $statement=$db->prepare($query);
    $statement->bindValue(':category_id',$category_id);
    $success = $statement->execute();
    $statement->closeCursor();

include('category_list.php')
 ?>