-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPublicationInfo.php
205 lines (101 loc) · 4.41 KB
/
PublicationInfo.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
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
{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 type=\"radio\" name=\"button\" value=\"button1\" id=\"button1\"> Print all of the publicationID By Year <br>";
echo "<input type=\"radio\" name=\"button\" value=\"button2\" id=\"button2\" > Print publicationID with 1000 with year <br>";
echo "<input type=\"radio\" name=\"button\" value=\"button3\" id=\"button3\" > Print all the publications with year <br>";
echo "<input type=\"radio\" name=\"button\" value=\"button4\" id=\"button4\"> Print all publications with year 2000 with language <br>";
echo "<input type=\"radio\" name=\"button\" value=\"button5\" id=\"button5\" > Print all books with language spanish <br>";
echo "<input type=\"submit\" value=\"Submit\">";
echo "</form>";
$selected= $_POST['button'];
// Print all of the publicationID By Year
if(isset($_POST['button'])) {
if($selected == "button1"){
echo"Printing all of the publicationID By Year <br>";
$sql = "SELECT publicationID,Year FROM `Publication`";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr> <th> PubllicationID</th> <th> Year</th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["publicationID"]. "</td> <td>". $row["Year"]. "</td> </tr>";
}
echo "</table>";
}
}
// Print publicationID with 1000 with year
if($selected == "button2"){
echo "Print publicationID with 1000 with year";
$sql = "SELECT publicationID,Year FROM `Publication` where publicationID = '1000'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr><th> PublicationID </th> <th> Year </th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["publicationID"]. "</td> <td>". $row["Year"]. "</td> </tr>";
}
echo "</table>";
}
}
// Print all the publications with year
if($selected == "button3"){
echo "Print all the publications with year";
$sql = "SELECT publicationID,Year FROM `Publication` WHERE 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr><th> PublicationID</th> <th> Year </th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["publicationID"]. "</td> <td>". $row["Year"]. "</td> </tr>";
}
echo "</table>";
}
}
// Print all publications with year 2000 with language
if($selected == "button4"){
echo "Print all publications with year 2000 with language <br>";
$sql = "SELECT Year,Language FROM `Publication` where Year=2000";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr><th> Year</th> <th> Language </th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["Year"]. "</td> <td>". $row["Language"]. "</td> </tr>";
}
echo "</table>";
}
}
//Print all books with language spanish
if($selected == "button5"){
echo "Print all books with language spanish";
$sql = "SELECT publicationID,Language FROM `Publication` where Language = 'Spanish'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo "<table border = \"1\">";
echo "<tr><th> PublicationID</th> <th> Language </th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr> <td>". $row["publicationID"]. "</td> <td>". $row["Language"]. "</td> </tr>";
}
echo "</table>";
}
}
}
$conn->close();
?>
{/source}