-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit_category.php
36 lines (32 loc) · 1.26 KB
/
edit_category.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
<?php
session_start();
include 'config/dbconnection.php';
if (isset($_GET['id'])) {
$id = $_GET['id'];
$result = $conn->query("SELECT * FROM categories WHERE id = $id");
if ($result) {
$row = $result->fetch_assoc();
if ($row) { ?>
<form id="update-category-form">
<div class="row g-3">
<div class="col-md-12">
<label for="category" class="form-label">Category Name</label>
<input type="hidden" name="category_id" value="<?php echo $row['id']; ?>">
<input type="text" name="category" value="<?php echo $row['name'] ?>" class="form-control" id="category" data-error-message="Category is required">
<div class="invalid-feedback"></div>
</div>
</div>
<div class="modal-footer">
<button type="reset" data-bs-dismiss="modal" class="btn btn-secondary">Cancel</button>
<button type="submit" class="btn btn-primary">Update Category</button>
</div>
</form>
<?php }
} else {
echo "Error executing the query.";
}
$conn->close();
} else {
echo "404 Error! No category found.";
}
?>