-
Notifications
You must be signed in to change notification settings - Fork 0
/
issue.php
40 lines (29 loc) · 1.01 KB
/
issue.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
<?php
require "connect.php";
$id = $_GET['reader_id'];
$issue = $_GET['issue'];
$book_id = $_GET['book_id'];
$sql = 'SELECT * FROM log WHERE book_id = "'.$book_id.'"';
$qry = mysqli_query($con, $sql);
if (mysqli_num_rows($qry) > 0) {
die('bool already issued');
}
if ($issue == 'y') {
$sql1 = 'UPDATE book SET reserve_status = "available", issue_status = "issued" WHERE book_id = "'.$book_id.'"';
$sql2 = 'DELETE FROM reserved WHERE book_id = "'.$book_id.'"';
$sql3 = 'INSERT INTO log VALUES ("'.$book_id.'", "'.$id.'")';
echo $sql1;
$qry1 = mysqli_query($con, $sql1);
$qry2 = mysqli_query($con, $sql2);
$qry3 = mysqli_query($con, $sql3);
} else if ($issue == 'n') {
$sql1 = 'UPDATE book SET reserve_status = "available" WHERE book_id = "'.$book_id.'"';
$sql2 = 'DELETE FROM reserved WHERE book_id = "'.$book_id.'"';
$qry1 = mysqli_query($con, $sql1);
$qry2 = mysqli_query($con, $sql2);
header("LOCATION: reserved_books.php");
} else {
die('choose a valid option');
}
header("LOCATION: reserved_books.php");
?>