-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturnbookquery.php
More file actions
44 lines (36 loc) · 954 Bytes
/
Copy pathreturnbookquery.php
File metadata and controls
44 lines (36 loc) · 954 Bytes
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
<?php
include 'assets/connect.php';
$isbn=$_GET["isbn"];
$card = $_GET["cid"];
$fine = $_GET["finetopay"];
$sql = "update book_loans set date_in=curdate() where isbn='$isbn' and card_id='$card'";
$res = mysqli_query($db,$sql);
/*if ($res)
echo "Book Successfully Returned.";*/
//$date=$parts[2];
$sql1 = "select loan_id,due_date from book_loans where isbn='$isbn' and card_id=$card";
$res1= mysqli_query($db,$sql1);
$row1 = $res1->fetch_assoc();
$l = $row1['loan_id'];
//$d = $row['due_date'];
$sql3 = "select loan_id from fines where loan_id=$l";
$res3 = mysqli_query($db,$sql3);
if($res3->num_rows > 0)
{
$sql4 = "update fines set fine_amt = fine_amt - $fine where loan_id = '$l'";
$res4 = mysqli_query($db,$sql4);
if($res4)
{
echo "Fines updated";
}
}
else
{
$sql5 = "insert into fines values('$l','$fine','1')";
$res5 = mysqli_query($db,$sql5);
if($res5)
{
echo "Fines paid";
}
}
?>