-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathps_details.php
69 lines (45 loc) · 1.57 KB
/
ps_details.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
<?php
//connect to db
include('config/db_connect_admin.php');
if (isset($_POST['delete'])) {
$id_to_delete = mysqli_real_escape_string($connect, $_POST['id_to_delete']);
$ps_sql = "DELETE FROM product_shelves WHERE shelf_id = $id_to_delete";
if (mysqli_query($connect, $ps_sql)) {
// success
header('Location: ps_index.php');
} else {
// faliure
echo 'query error: ' . mysqli_error($connect);
}
}
// check get request id parameter
if (isset($_GET['id'])) {
$ps_id = mysqli_real_escape_string($connect, $_GET['id']);
// make sql
$ps_sql = "SELECT * FROM product_shelves WHERE shelf_id = $ps_id";
// get query result
$ps_result = mysqli_query($connect, $ps_sql);
// fetch result in array format
$product_shelves = mysqli_fetch_assoc($ps_result);
mysqli_free_result($ps_result);
mysqli_close($connect);
}
?>
<!DOCTYPE html>
<html>
<?php include('templates/header.php'); ?>
<div class="container center darkslategray-text">
<?php if($product_shelves): ?>
<h4><?php echo htmlspecialchars($product_shelves['category']); ?></h4>
<p>Type: <?php echo htmlspecialchars($product_shelves['type']); ?></p>
<!-- Delete form -->
<form action="ps_details.php" method="POST">
<input type="hidden" name="id_to_delete" value="<?php echo $product_shelves['shelf_id'] ?>">
<input type="submit" name="delete" value="Delete" class="btn brand z-depth-0">
</form>
<?php else: ?>
<h5>No such Product Shelf exist!</h5>
<?php endif; ?>
</div>
<?php include('templates/footer.php'); ?>
</html>