-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteCategory.php
33 lines (33 loc) · 975 Bytes
/
deleteCategory.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
<?php
require_once "classes/DBAccess.php";
$title = "Delete";
//$pageHeading = "Categories";
//get database settings
include "settings/db.php";
//create database object
$db = new DBAccess($dsn, $username, $password);
//connect to database
$pdo = $db->connect();
$message = "";
//get category id to delete
if(!empty($_GET["id"]))
{
//set up query to execute
$sql = "delete from category where categoryID=:categoryID";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(":categoryID" , $_GET["id"], PDO::PARAM_INT);
//execute SQL query
$db->executeNonQuery($stmt, false);
$message = "The category was deleted";
}
//select all categories to display in a table
$sql = "select categoryId, categoryName from category";
$stmt = $pdo->prepare($sql);
$categoryRows = $db->executeSQL($stmt);
//start buffer
ob_start();
//display categories
include "templates/Authentication/deleteCategoryForm.html.php";
$output = ob_get_clean();
include "templates/Authentication/updateLayout.html.php";
?>