-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReturnedInfo.php
More file actions
269 lines (149 loc) · 6.23 KB
/
Copy pathReturnedInfo.php
File metadata and controls
269 lines (149 loc) · 6.23 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
{source}
<?php
$servername = "localhost";
$username = "group2";
$password = "group2";
$dbname = "group2";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "<form method = \"POST\" action=\"\">";
echo "<input checked=\"\" type=\"radio\" name=\"button\" value=\"button1\" id=\"button1\"> print all the memberIDs who have returned books<br>";
echo "<input type=\"radio\" name=\"button\" value=\"button2\" id=\"button2\" > print all the books which were returned<br>";
echo "<input type=\"radio\" name=\"button\" value=\"button3\" id=\"button3\" > print all the dates when books were returned<br>";
echo "<input type=\"radio\" name=\"button\" value=\"button4\" id=\"button4\" >print memberIDs who have returned books between date 2020-01-31 and 2020-02-28<br>";
echo "<input type=\"radio\" name=\"button\" value=\"button5\" id=\"button5\" >print all the books which are returned between 2020-01-31 and 2020-02-28 <br>";
echo "<input type=\"radio\" name=\"button\" value=\"button6\" id=\"button6\" >print all the dates between 2020-02-02 and 2020-02-04 when all the books where returned <br>";
echo "<input type=\"radio\" name=\"button\" value=\"button7\" id=\"button7\" >print How many books were returned in year place a year or date in here ex: 2019<br>";
echo "<input type=\"radio\" name=\"button\" value=\"button8\" id=\"button8\" > Print the book having ISBNumber 100 which is returned by member of (ID: 710986)<br>";
echo "<input type=\"submit\" value=\"Submit\">";
echo "</form>";
$selected= $_POST['button'];
// print all the memberIDs who have returned books
if(isset($_POST['button'])) {
if($selected == "button1"){
echo "Printing all the memberIDs who have returned books ";
$sql = " SELECT MemberID FROM `Returned`";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr> <th> MemberID</th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["MemberID"]. "</td> </tr>";
}
echo "</table>";
}
}
// print all the books which were returned
if($selected == "button2"){
echo "Printing all the books which were returned ";
$sql = " SELECT ISBNumber FROM `Returned`";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr><th> ISBNumber </th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["ISBNumber"]. "</td> </tr>";
}
echo "</table>";
}
}
// print all the dates when books were returned
if($selected == "button3"){
echo "Printing all the dates when books were returned ";
$sql = " SELECT returnDate FROM `Returned`";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr> <th> returnDate </th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["returnDate"]. "</td> </tr>";
}
echo "</table>";
}
}
// print memberIDs who have returned books between date 2020-01-31 and 2020-02-28
if($selected == "button4"){
echo "Printing memberIDs who have returned books between date 2020-01-31 and 2020-02-28";
$sql = " SELECT MemberID FROM `Returned` WHERE ReturnDate BETWEEN '2020-01-31' and '2020-02-28' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr> <th> MemberID </th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["MemberID"]. "</td> </tr>";
}
echo "</table>";
}
}
// print all the books which are returned between 2020-01-31 and 2020-02-28
if($selected == "button5"){
echo "Printing all the books which are returned between 2020-01-31 and 2020-02-28";
$sql = " SELECT ISBNumber FROM `Returned` WHERE ReturnDate BETWEEN '2020-01-31' and '2020-02-28' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr> <th> ISBNumber </th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["ISBNumber"]. "</td> </tr>";
}
echo "</table>";
}
}
// print all the dates between 2020-02-02 and 2020-02-04 when all the books where returned
if($selected == "button6"){
echo "Printing all the dates between 2020-02-02 and 2020-02-04 when all the books where returned ";
$sql = " SELECT ReturnDate FROM `Returned` WHERE ReturnDate BETWEEN '2020-02-02' and '2020-02-04'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr> <th> ReturnDate </th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["ReturnDate"]. "</td> </tr>";
}
echo "</table>";
}
}
// print How many books were returned in year place a year or date in here ex: 2019
if($selected == "button7"){
echo "Printing How many books were returned in year place a year or date in here ex: 2019";
$sql = " SELECT COUNT(ISBNumber) FROM `Returned` WHERE ReturnDate BETWEEN '2020-02-04' AND '2020-12-08'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr> <th> COUNT(ISBNumber) </th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["COUNT(ISBNumber)"]. "</td> </tr>";
}
echo "</table>";
}
}
// Print the book having ISBNumber 100 which is returned by member of (ID: 710986)
if($selected == "button8"){
echo "Printing the book having ISBNumber 100 which is returned by member of (ID: 710986)";
$sql = " SELECT ISBNumber, MemberID FROM `Returned` WHERE ISBNumber='100' AND MemberID = 710986";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr> <th> ISBNumber </th> <th> MemberID </th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["ISBNumber"]. "</td><td>". $row["MemberID"]. "</td> </tr>";
}
echo "</table>";
}
}
}
$conn->close();
?>
{/source}