-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsellingRemoval.html
101 lines (84 loc) · 3.26 KB
/
sellingRemoval.html
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!--this is where we should use firebase connection-->
<!--<?php
//session_start();
?>-->
<!DOCTYPE html>
<script src="https://www.gstatic.com/firebasejs/4.6.2/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyAKAvtSqE25LzqCWv4PzPlHuC9a-UadF7U",
authDomain: "studyswapwebsite.firebaseapp.com",
databaseURL: "https://studyswapwebsite.firebaseio.com",
projectId: "studyswapwebsite",
storageBucket: "studyswapwebsite.appspot.com",
messagingSenderId: "271728404472"
};
firebase.initializeApp(config);
</script>
<html>
<head>
<title>Last 10 Results</title>
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/buyTextBooks.css" rel="stylesheet">
<link href="../css/contactus.css" rel="stylesheet">
<link href="../css/carousel.css" rel="stylesheet">
<!-- trying to link javascript for it to work-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<?php
//Address error handling
ini_set('display_errors', 1);
//error_reporting(E_ALL & E_NOTICE);
//Attempt to connect
if($connection=@mysql_connect('localhost', 'tshay1', 'DHS23Hornets')){
//print '<p>Successfully connected to MySQL.</p>';
}else{
die('<p>Could not connect to MySQL because:<b>'.mysql_error().'</b></p>');
}
if(@mysql_select_db("tshay1DB", $connection)){
//print '<p> The tshay1DB database has been selected</p>';
}else{
die('<p>Could not select the tshay1DB database because:<b>'.mysql_error().'</b></p>');
}
$isbnSellRemove=$_POST['isbnForSelling'];
$conditionSellRemove=$_POST['conditionForSelling'];
$sellPriceRemove=$_POST['priceForSelling'];
$userIDRemove=$_POST['userIDForSelling'];
$try = "DELETE FROM selling WHERE isbnSelling='$isbnSellRemove' AND `condition`='$conditionSellRemove' AND sellPrice='$sellPriceRemove' AND userIDSelling='$userIDRemove'";
$results=mysql_query($try);
if (!$results)
{ // add this check.
die('Invalid query: ' . mysql_error());
}
else
{?>
<?php
$getQuantityOfBook="SELECT quantity FROM books WHERE ISBN='$isbnSellRemove'";
if($r=mysql_query($getQuantityOfBook))
{
$row=mysql_fetch_array($r);
echo $row['quantity'];
}
if($row['quantity']>1)
{
$updateQuantityQuery="UPDATE books SET quantity = quantity - 1 WHERE ISBN = '$isbnSellRemove'";
if($r=mysql_query($updateQuantityQuery))
{
echo 'Successfully removed that book from the sales listings! Updated books quantity! <a href="viewSellingBooks.html">Go back</a>';
}
}
else
{
$updateQuantityQuery="DELETE FROM books WHERE ISBN = '$isbnSellRemove'";
if($r=mysql_query($updateQuantityQuery))
{
echo 'Successfully removed that book from the sales listings! Updated books quantity! <a href="viewSellingBooks.html">Go back</a>';
}
}
}
?>
</body>
</html>