-
Notifications
You must be signed in to change notification settings - Fork 2
/
displayselectedbiological.php
229 lines (197 loc) · 7.11 KB
/
displayselectedbiological.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!DOCTYPE html>
<html lang="en">
<head>
<title>Download</title>
<meta name="description" content="">
<meta name="author" content="">
</head>
<body>
<?php include_once("header.php");?>
<div class="container">
<div class="text-center">
<h1>Marine</h1>
<p class="lead">Selected data</p>
</div>
<ul>
<li>Click on download to obtain the data in csv form </li>
</ul>
<?php
if(isset($_POST['submit'])){
$table = $_POST['table'];
if($table = 'station'){
if(!empty($_POST['station_list'])) {
// Counting number of checked checkboxes.
$checked_count = count($_POST['station_list']);
echo "<p>";
echo "You have selected following station(s): <br/>";
// Loop to store and display values of individual checked checkbox.
foreach($_POST['station_list'] as $selected) {
echo " - ".$selected . "";
}
echo "</p>";
include("db.php");
$name = $_POST['station_list'];
$sql = "SELECT Sname AS Name, Slongitude AS Longitude, Slatitude AS Latitude
FROM Stations
WHERE Sname IN ('" . implode("','", $name) ."') AND Shidden = 0
;
";
if (mysqli_query($conn, $sql)) {
$result = mysqli_query($conn, $sql);
$num = mysqli_num_rows($result);
echo "<b>Stations</b><br>";
echo "<table class=\"table\" id=\"datatable\">";
echo "<thead>";
echo "<tr><th>Station name</th><th>Longitude</th><th>Latitude</th></tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr><td>" . $row["Name"]."</td>";
echo "<td>" . $row["Longitude"]."</td>";
echo "<td>" . $row["Latitude"]."</td></tr>";
}
echo "</tbody>";
echo "</table>";
mysqli_close($conn);
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
else{
// echo "<b>No stations selected.</b> </p>";
}
}
if($table = 'physical'){
if(!empty($_POST['station_forphysical'])) {
if(!empty($_POST['depth_physical'])) {
// Counting number of checked checkboxes.
$checked_count = count($_POST['station_forphysical']);
echo "<p>";
echo "You have selected following station(s): <br/>";
// Loop to store and display values of individual checked checkbox.
foreach($_POST['station_forphysical'] as $selected) {
echo " - ".$selected . "";
}
echo "</p>";
$checked_count = count($_POST['depth_physical']);
echo "<p>";
echo "You have selected following depth(s): <br/>";
// Loop to store and display values of individual checked checkbox.
foreach($_POST['depth_physical'] as $selected) {
echo " - ".$selected . "";
}
echo "</p>";
include("db.php");
$station = $_POST['station_forphysical'];
$depth = $_POST['depth_physical'];
$sql = "SELECT Pstationname AS Name, Pdepth AS Depth, Ptemperature AS Temperature, Psalinity AS Salinity, POxygen AS Oxygen, Pfluorescence AS Fluorescence
FROM Physical
WHERE Pstationname IN ('" . implode("','", $station) ."') AND Pdepth IN ('" . implode("','", $depth) ."') AND Phidden = 0
ORDER BY Pdepth, Pstationname
;
";
if (mysqli_query($conn, $sql)) {
$result = mysqli_query($conn, $sql);
$num = mysqli_num_rows($result);
echo "<b>Physical samples</b><br>";
echo "<table class=\"table\" id=\"datatable\">";
echo "<thead>";
echo "<tr><th>Station name</th><th>Depth</th><th>Temperature</th><th>Salinity</th><th>Oxygen</th><th>Fluorescence</th></tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr><td>" . $row["Name"]."</td>";
echo "<td>" . $row["Depth"]."</td>";
echo "<td>" . $row["Temperature"]."</td>";
echo "<td>" . $row["Salinity"]."</td>";
echo "<td>" . $row["Oxygen"]."</td>";
echo "<td>" . $row["Fluorescence"]."</td></tr>";
}
echo "</tbody>";
echo "</table>";
mysqli_close($conn);
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
}
else{
// echo "<b>No stations selected.</b> </p>";
}
}
if($table = 'biological'){
if(!empty($_POST['station_forbiological'])) {
// Counting number of checked checkboxes.
$checked_count = count($_POST['station_forbiological']);
echo "<p>";
echo "You have selected following station(s): <br/>";
// Loop to store and display values of individual checked checkbox.
foreach($_POST['station_forbiological'] as $selected) {
echo " - ".$selected . "";
}
echo "</p>";
$checked_count = count($_POST['biological_stratummax']);
echo "<p>";
echo "You have selected following stratum(s): <br/>";
// Loop to store and display values of individual checked checkbox.
foreach($_POST['biological_stratummax'] as $selected) {
echo " - ".$selected . "";
}
echo "</p>";
$checked_count = count($_POST['biological_larval']);
echo "<p>";
echo "You have selected following larval stage(s): <br/>";
// Loop to store and display values of individual checked checkbox.
foreach($_POST['biological_larval'] as $selected) {
echo " - ".$selected . "";
}
echo "</p>";
$checked_count = count($_POST['biological_species']);
echo "<p>";
echo "You have selected following specie(s): <br/>";
// Loop to store and display values of individual checked checkbox.
foreach($_POST['biological_species'] as $selected) {
echo " - ".$selected . "";
}
echo "</p>";
include("db.php");
$station = $_POST['station_forbiological'];
$stratum = $_POST['biological_stratummax'];
$larva = $_POST['biological_larval'];
$species = $_POST['biological_species'];
$sql = "SELECT Bstationname AS Name, Bstratummax AS Stratum, Blarvastage AS LarvalStage, Bspecies AS Species, Babundance AS Abundance
FROM Biological
WHERE Bstationname IN ('" . implode("','", $station) ."') AND Bstratummax IN ('" . implode("','", $stratum) ."') AND Blarvastage IN ('" . implode("','", $larva) ."') AND Bspecies IN ('" . implode("','", $species) ."') AND Bhidden = 0
ORDER BY Bstratummax, Bstationname, Blarvastage, Babundance
;
";
if (mysqli_query($conn, $sql)) {
$result = mysqli_query($conn, $sql);
$num = mysqli_num_rows($result);
echo "<b>Physical samples</b><br>";
echo "<table class=\"table\" id=\"datatable\">";
echo "<thead>";
echo "<tr><th>Station name</th><th>Stratum</th><th>Larval Stage</th><th>Species</th><th>Abundance</th></tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr><td>" . $row["Name"]."</td>";
echo "<td>" . $row["Stratum"]."</td>";
echo "<td>" . $row["LarvalStage"]."</td>";
echo "<td>" . $row["Species"]."</td>";
echo "<td>" . intval($row["Abundance"])."</td></tr>";
}
echo "</tbody>";
echo "</table>";
mysqli_close($conn);
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
}
}
?>
<a download="somedata.csv" href="#" onclick="return ExcellentExport.csv(this, 'datatable');">Export to CSV</a>
</div><!-- /.container -->
</body>
</html>