-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin_edit.php
87 lines (83 loc) · 2.5 KB
/
admin_edit.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
session_start();
require_once "./functions/admin_functions.php";
require_once "./functions/database_functions.php";
$conn = db_connect();
require "./template/menu.php";
if(isset($_GET['bookisbn'])){
$book_isbn = $_GET['bookisbn'];
} else {
echo "Empty query!";
exit;
}
if(!isset($book_isbn)){
echo "Empty isbn! check again!";
exit;
}
// get book data
$query = "SELECT * FROM books WHERE book_isbn = '$book_isbn'";
$result = mysqli_query($conn, $query);
if(!$result){
echo "Can't retrieve data " . mysqli_error($conn);
exit;
}
$row = mysqli_fetch_assoc($result);
$queryForCategory="SELECT * from category";
$resultForCategory = mysqli_query($conn, $queryForCategory);
?>
<form method="post" action="edit_book.php" enctype="multipart/form-data">
<table class="table">
<tr>
<th>ISBN</th>
<td><input type="text" name="isbn" value="<?php echo $row['book_isbn'];?>" readOnly="true"></td>
</tr>
<tr>
<th>Title</th>
<td><input type="text" name="title" value="<?php echo $row['book_title'];?>" required></td>
</tr>
<tr>
<th>Author</th>
<td><input type="text" name="author" value="<?php echo $row['book_author'];?>" required></td>
</tr>
<tr>
<th>Image</th>
<td><input type="file" name="image"></td>
</tr>
<tr>
<th>Description</th>
<td><textarea name="descr" cols="40" rows="5"><?php echo $row['book_descr'];?></textarea>
</tr>
<tr>
<th>Price</th>
<td><input type="text" name="price" value="<?php echo $row['book_price'];?>" required></td>
</tr>
<tr>
<th>Publisher</th>
<td><input type="text" name="publisher" value="<?php echo getPubName($conn, $row['publisherid']); ?>" required></td>
</tr>
<tr>
<th>Category</th>
<td>
<select name="category">
<?php $count =0; while($category = mysqli_fetch_assoc($resultForCategory)){ $count=$count+1; ?>
<option value="<?php echo $category["category_id_pk"]?>" <?php
if ($row['category_id_fk']==$category["category_id_pk"]) {
echo 'selected="selected"';
}
?>>
<?php echo $category["name"]?>
</option>
<?php }?>
</select>
</td>
</tr>
<tr>
<th>Quantity</th>
<td><input type="text" name="quantity" value="<?php echo $row['quantity']; ?>" ></td>
</tr>
</table>
<input type="submit" name="save_change" value="Change" class="btn btn-primary">
<input type="reset" value="cancel" class="btn btn-default">
</form>
<br/>
<a href="admin_book.php" class="btn btn-success">Confirm</a>